-
Notifications
You must be signed in to change notification settings - Fork 0
/
github_cog.py
62 lines (49 loc) · 1.84 KB
/
github_cog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import discord
from discord import app_commands
from discord.ext import commands
from bot import GwaffBot
from custom_logger import Logger
logger = Logger('gwaff.bot.github')
from permissions import require_admin
class GithubCog(commands.GroupCog, group_name='github'):
def __init__(self, bot: GwaffBot):
self.bot = bot
self.bot.schedule_task(
self.upload,
trigger="cron",
hour=1,
timezone="Australia/Brisbane",
day='last'
)
async def upload(self):
logger.info("Starting upload")
if self.bot.logging_channel:
await self.bot.logging_channel.send("Hello!")
else:
logger.warning(f"Could not find required channel")
logger.info("Upload was not completed successfully")
@app_commands.command(name="upload",
description="(Admin only) Upload the data to github")
@require_admin
async def command_upload(self, interaction: discord.Interaction):
await interaction.response.defer(ephemeral=True)
await self.upload()
await interaction.followup.send("No such luck")
@app_commands.command(name="update",
description="(Admin only) Update the bot from github")
@require_admin
async def update(self, interaction: discord.Interaction):
await interaction.response.defer(ephemeral=True)
# logger.info("Starting update")
await interaction.followup.send("No such luck")
logger.warning("Update was not completed successfully")
async def scheduled_upload(self):
await self.upload()
async def setup(bot: GwaffBot):
"""
Sets up the GithubCog and adds it to the bot.
Args:
bot (GwaffBot): The bot instance.
"""
cog = GithubCog(bot)
await bot.add_cog(cog, guilds=bot.guilds)