diff --git a/cogs/assignments.py b/cogs/assignments.py index c61697f..2dcdef2 100644 --- a/cogs/assignments.py +++ b/cogs/assignments.py @@ -430,7 +430,7 @@ class AssignmentsCog(commands.Cog): super().__init__(timeout=300) async def interaction_check(self, interaction: discord.Interaction) -> bool: - return interaction.user == ctx.author + return interaction.user == ctx.user async def on_timeout(self) -> None: await self.message.delete(delay=0.1) diff --git a/cogs/mod.py b/cogs/mod.py index ab745d4..6d409a1 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -1,7 +1,6 @@ import discord from discord.ext import commands from utils import Student, get_or_none, BannedStudentID -import orm class Mod(commands.Cog): @@ -24,7 +23,7 @@ class Mod(commands.Cog): associated_account=member.id, ) - await member.ban(reason=f"Banned ID {ban.student_id} by {ctx.author}") + await member.ban(reason=f"Banned ID {ban.student_id} by {ctx.user}") return await ctx.respond( f"\N{white heavy check mark} Banned {ban.student_id} (and {member.mention})", ephemeral=True ) @@ -44,7 +43,7 @@ class Mod(commands.Cog): return await ctx.respond(f"\N{white heavy check mark} Unbanned {student_id}. No user to unban.") else: try: - await ctx.guild.unban(discord.Object(user_id), reason=f"Unbanned by {ctx.author}") + await ctx.guild.unban(discord.Object(user_id), reason=f"Unbanned by {ctx.user}") except discord.HTTPException as e: return await ctx.respond( f"\N{white heavy check mark} Unbanned {student_id}. Failed to unban {user_id} - HTTP {e.status}." diff --git a/cogs/timetable.py b/cogs/timetable.py index 29d55d4..21e3e5f 100644 --- a/cogs/timetable.py +++ b/cogs/timetable.py @@ -1,6 +1,5 @@ -import asyncio import sys -from typing import Optional, Union, Dict, Callable +from typing import Optional, Union, Dict import discord from discord.ext import commands, tasks @@ -239,7 +238,7 @@ class TimeTableCog(commands.Cog): date = datetime.now() text = self.format_timetable_message(date) - view = TimeTableDaySwitcherView(ctx.author, self, date) + view = TimeTableDaySwitcherView(ctx.user, self, date) view.update_buttons() await ctx.respond(text, view=view) diff --git a/cogs/verify.py b/cogs/verify.py index 8f16f4c..e1dabdd 100644 --- a/cogs/verify.py +++ b/cogs/verify.py @@ -14,19 +14,19 @@ class VerifyCog(commands.Cog): """Verifies or generates a verification code""" try: - student: Student = await Student.objects.get(user_id=ctx.author.id) + student: Student = await Student.objects.get(user_id=ctx.user.id) return await ctx.respond(f"\N{cross mark} You're already verified as {student.id}!", ephemeral=True) except orm.NoMatch: pass role = discord.utils.find(lambda r: r.name.lower() == "verified", ctx.guild.roles) channel = discord.utils.get(ctx.guild.text_channels, name="verify") - if role in ctx.author.roles: + if role in ctx.user.roles: if role and role < ctx.me.top_role: - await ctx.author.remove_roles(role, reason=f"Auto de-verified") + await ctx.user.remove_roles(role, reason=f"Auto de-verified") if channel: try: - await ctx.author.send( + await ctx.user.send( f"You have been automatically de-verified. Please re-verify by going to {channel.mention} " f"and typing ." ) diff --git a/main.py b/main.py index 9dd5773..089f16a 100644 --- a/main.py +++ b/main.py @@ -28,7 +28,7 @@ async def on_connect(): @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) - raise error + raise error from None @bot.listen("on_command_error") @@ -36,7 +36,7 @@ async def on_command_error(ctx: commands.Context, error: Exception): if isinstance(error, commands.CommandNotFound): return await ctx.reply("Command Error: `%r`" % error) - raise error + raise error from None @bot.listen("on_application_command")