diff --git a/.idea/dataSources/28efee07-d306-4126-bf69-01008b4887e2.xml b/.idea/dataSources/28efee07-d306-4126-bf69-01008b4887e2.xml index f162f8f..889658c 100644 --- a/.idea/dataSources/28efee07-d306-4126-bf69-01008b4887e2.xml +++ b/.idea/dataSources/28efee07-d306-4126-bf69-01008b4887e2.xml @@ -1,9 +1,7 @@ - - 3.39.2 - + diff --git a/cogs/events.py b/cogs/events.py index 4a38592..408ba9c 100644 --- a/cogs/events.py +++ b/cogs/events.py @@ -13,23 +13,26 @@ RTL = "\N{leftwards black arrow}\U0000fe0f" class Events(commands.Cog): def __init__(self, bot): - self.bot = bot + self.bot: commands.Bot = bot self.lupupa_warning_task.start() def cog_unload(self): self.lupupa_warning_task.stop() - @tasks.loop(minutes=2) + @tasks.loop(minutes=30) async def lupupa_warning_task(self): + lupupa_warning_text = "\N{warning sign} Lupupa warning!!!" if lupupa_warning and datetime.now().strftime("%A") == "Thursday": - now = datetime.now().time() - if (now.hour == 10 and now.minute in range(0, 2)) or (now.hour == 11 and now.minute in range(29, 32)): - channel = discord.utils.get(self.bot.get_guild(guilds[0]).text_channels, name="general") - if channel and channel.can_send(): - await channel.send( - "Uh oh, Lupupa warning! Make sure you've got your essays written in academic style in Microsoft" - " Word on your pen drive! You aren't in primary school anymore!" - ) + if self.bot.activity.name != lupupa_warning_text: + await self.bot.change_presence( + activity=discord.Activity( + name=lupupa_warning_text, + type=discord.ActivityType.watching + ), + status=discord.Status.dnd + ) + else: + await self.bot.change_presence() @commands.Cog.listener("on_raw_reaction_add") async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent): diff --git a/main.py b/main.py index be00e29..f34500e 100644 --- a/main.py +++ b/main.py @@ -30,6 +30,11 @@ async def on_connect(): console.log("[green]Connected to discord!") +@bot.listen("on_application_command_error") +async def on_application_command_error(ctx: discord.ApplicationContext, error: Exception): + await ctx.respond("Application Command Error: `%r`" % error) + + @bot.event async def on_ready(): console.log("Logged in as", bot.user)