From c77edad98d11144cbfb90f19797cc6fc3ef09d53 Mon Sep 17 00:00:00 2001 From: Aaryan <44059614+AaryanHazCompter@users.noreply.github.com> Date: Fri, 5 Apr 2024 03:28:28 -0600 Subject: [PATCH 1/3] Schedubuddy cog 2024-25 compliance The Schedubuddy cog has accounted for 2023-24 cases up until now, made minor changes to continue compliance for the upcoming year. --- cogs/schedubuddy.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cogs/schedubuddy.py b/cogs/schedubuddy.py index ef33f6a..2ea756b 100644 --- a/cogs/schedubuddy.py +++ b/cogs/schedubuddy.py @@ -163,16 +163,16 @@ async def cog_load(self): def get_term_id(self, year: str, term: str): match (year.value, term.value): - case ("2023", "Winter"): - return "1820" - case ("2023", "Spring"): - return "1830" - case ("2024", "Summer"): - return "1840" - case ("2023", "Fall"): - return "1850" case ("2024", "Winter"): return "1860" + case ("2024", "Spring"): + return "1870" + case ("2024", "Summer"): + return "1880" + case ("2024", "Fall"): + return "1890" + case ("2025", "Winter"): + return "1900" case _: return "" @@ -192,8 +192,8 @@ def get_term_id(self, year: str, term: str): @app_commands.describe(year="The year to view the schedule for.") @app_commands.choices( year=[ - app_commands.Choice(name="2023", value="2023"), app_commands.Choice(name="2024", value="2024"), + app_commands.Choice(name="2025", value="2025"), ] ) @app_commands.describe(room="The room to view the schedule for. Eg CAB 239") @@ -241,8 +241,8 @@ async def view( @app_commands.describe(year="The year to view the schedule for.") @app_commands.choices( year=[ - app_commands.Choice(name="2023", value="2023"), app_commands.Choice(name="2024", value="2024"), + app_commands.Choice(name="2025", value="2025"), ] ) @app_commands.describe( From 10d1e4d34398e2ae353ed270266b8a59e6f12ce8 Mon Sep 17 00:00:00 2001 From: Aaryan <44059614+AaryanHazCompter@users.noreply.github.com> Date: Fri, 5 Apr 2024 05:48:57 -0600 Subject: [PATCH 2/3] add sherpmail I saw an issue Ian raised about wanting a way to (a) communicate to the server through the bot (b) have the server communicate to him through the bot and the idea seemed funny so I coded it - there's little error handling, no accounting for excess characters, no graphics and attachment handling, and definitely no spam prevention - however I am sleep deprived and wanted to make what is basically a letter mail system work to a reasonable extent. --- cogs/sherpmail.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 cogs/sherpmail.py diff --git a/cogs/sherpmail.py b/cogs/sherpmail.py new file mode 100644 index 0000000..832c4d4 --- /dev/null +++ b/cogs/sherpmail.py @@ -0,0 +1,68 @@ +import discord +from discord.ext import commands +from discord import app_commands + +# I couldn't work out replying directly to the initial messages so this is not the best +# Nonetheless it is nearly 6am and I felt the need to complete this +# I hope it works out and nobody abuses it lol good luck + +class sherpMailbox(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.sherp = "" + + async def cog_load(self): + await super().cog_load() + print("Sherpmail loaded.") + + @app_commands.command( + name = "sherpmail", + description = "Leave a message directly to Sherp's DMs" + ) + @app_commands.describe( + msg = "The message you would like to leave for Sherp (be respectful)" + ) + async def sendMessage(self, interaction: discord.Interaction, msg: str): + # Sherp's Discord ID is currently 212613981465083906 + self.sherp = await interaction.client.fetch_user(212613981465083906) + try: + embed = discord.Embed( + title = f"📬 You've got mail! **@{interaction.user} | ID: {interaction.user.id}** sent you the following:", + description = f"{msg}", + colour = discord.Colour.gold() + ) + await self.sherp.send(embed = embed) + + embed = discord.Embed( + title = f"📫 Outgoing! The following message has been mailed to {self.sherp.display_name}:", + description = f"{msg}", + colour = discord.Colour.green() + ) + await interaction.response.send_message(embed = embed) + except: + await interaction.response.send_message(f"❌ An unexpected error has occurred!") + + @commands.Cog.listener() + async def on_message(self, message: discord.Message): + if (message.guild == None) and (message.author.id == 214657501193306112): + try: + embed = discord.Embed( + title = "📬 You've got mail! This is what Sherp said:", + description = f"{message.content}", + colour = discord.Colour.gold() + ) + # I used the ID 1183281507842924645 from the channel "non-cs-nonsense" + ch = self.bot.get_channel(1183281507842924645) + await ch.send(embed = embed) + + embed = discord.Embed( + title = f"📫 Outgoing! The following reply was sent:", + description = f"{message.content}", + colour = discord.Colour.green() + ) + await message.reply(embed = embed, mention_author = False) + except: + await message.reply(f"❌ An unexpected error has occurred!") + +async def setup_sherpMailbox_cog(bot, guilds): + await bot.add_cog(sherpMailbox(bot), guilds=guilds) \ No newline at end of file From 12f1c84458464e46d748c5aa321a16c67ada3004 Mon Sep 17 00:00:00 2001 From: Aaryan <44059614+AaryanHazCompter@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:30:04 -0600 Subject: [PATCH 3/3] Revert "add sherpmail" This reverts commit 10d1e4d34398e2ae353ed270266b8a59e6f12ce8. --- cogs/sherpmail.py | 68 ----------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 cogs/sherpmail.py diff --git a/cogs/sherpmail.py b/cogs/sherpmail.py deleted file mode 100644 index 832c4d4..0000000 --- a/cogs/sherpmail.py +++ /dev/null @@ -1,68 +0,0 @@ -import discord -from discord.ext import commands -from discord import app_commands - -# I couldn't work out replying directly to the initial messages so this is not the best -# Nonetheless it is nearly 6am and I felt the need to complete this -# I hope it works out and nobody abuses it lol good luck - -class sherpMailbox(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.sherp = "" - - async def cog_load(self): - await super().cog_load() - print("Sherpmail loaded.") - - @app_commands.command( - name = "sherpmail", - description = "Leave a message directly to Sherp's DMs" - ) - @app_commands.describe( - msg = "The message you would like to leave for Sherp (be respectful)" - ) - async def sendMessage(self, interaction: discord.Interaction, msg: str): - # Sherp's Discord ID is currently 212613981465083906 - self.sherp = await interaction.client.fetch_user(212613981465083906) - try: - embed = discord.Embed( - title = f"📬 You've got mail! **@{interaction.user} | ID: {interaction.user.id}** sent you the following:", - description = f"{msg}", - colour = discord.Colour.gold() - ) - await self.sherp.send(embed = embed) - - embed = discord.Embed( - title = f"📫 Outgoing! The following message has been mailed to {self.sherp.display_name}:", - description = f"{msg}", - colour = discord.Colour.green() - ) - await interaction.response.send_message(embed = embed) - except: - await interaction.response.send_message(f"❌ An unexpected error has occurred!") - - @commands.Cog.listener() - async def on_message(self, message: discord.Message): - if (message.guild == None) and (message.author.id == 214657501193306112): - try: - embed = discord.Embed( - title = "📬 You've got mail! This is what Sherp said:", - description = f"{message.content}", - colour = discord.Colour.gold() - ) - # I used the ID 1183281507842924645 from the channel "non-cs-nonsense" - ch = self.bot.get_channel(1183281507842924645) - await ch.send(embed = embed) - - embed = discord.Embed( - title = f"📫 Outgoing! The following reply was sent:", - description = f"{message.content}", - colour = discord.Colour.green() - ) - await message.reply(embed = embed, mention_author = False) - except: - await message.reply(f"❌ An unexpected error has occurred!") - -async def setup_sherpMailbox_cog(bot, guilds): - await bot.add_cog(sherpMailbox(bot), guilds=guilds) \ No newline at end of file