diff --git a/src/bot/cogs/admin/points.py b/src/bot/cogs/admin/points.py index a5a9f6d..90c768b 100644 --- a/src/bot/cogs/admin/points.py +++ b/src/bot/cogs/admin/points.py @@ -202,7 +202,7 @@ async def on_message(self, message) -> None: """ if message.author.bot: return - if message.guild.id != int(os.getenv("MASTER_GUILD")): + if message.guild is None or message.guild.id != int(os.getenv("MASTER_GUILD")): return msg = message.content.split() @@ -219,6 +219,9 @@ async def on_message_delete(self, message): """ if message.author.bot: return + if message.guild is None or message.guild.id != int(os.getenv("MASTER_GUILD")): + return + msg = message.content.split() logger.debug( f"Updating -{len(msg)} points for {message.author.display_name} for deleting a message." diff --git a/src/bot/cogs/moderation/admin_automod_spam_messages.py b/src/bot/cogs/moderation/admin_automod_spam_messages.py index dd4130e..1b2f01f 100644 --- a/src/bot/cogs/moderation/admin_automod_spam_messages.py +++ b/src/bot/cogs/moderation/admin_automod_spam_messages.py @@ -96,8 +96,8 @@ async def on_message(self, message): author_id = message.author.id content = message.content or "" - if message.attachments: - attachment = message.attachments[0] + attachment = message.attachments[0] if message.attachments else None + if attachment: content += hashlib.sha256( f"|{attachment.filename}|{attachment.size}|{attachment.content_type}".encode() ).hexdigest() @@ -142,11 +142,11 @@ async def on_message(self, message): { "message_id": message.id, "channel_id": message.channel.id, - "file_name": message.attachments[0].filename - if not message.content + "file_name": attachment.filename + if attachment and not message.content else None, - "file_url": message.attachments[0].url - if not message.content + "file_url": attachment.url + if attachment and not message.content else None, } ) @@ -163,11 +163,11 @@ async def on_message(self, message): { "message_id": message.id, "channel_id": message.channel.id, - "file_name": message.attachments[0].filename - if not message.content + "file_name": attachment.filename + if attachment and not message.content else None, - "file_url": message.attachments[0].url - if not message.content + "file_url": attachment.url + if attachment and not message.content else None, } ], diff --git a/src/bot/cogs/moderation/admin_mute.py b/src/bot/cogs/moderation/admin_mute.py index 87bae16..13c075a 100644 --- a/src/bot/cogs/moderation/admin_mute.py +++ b/src/bot/cogs/moderation/admin_mute.py @@ -60,7 +60,6 @@ async def mute_member( """ if not target.bot: - logger.info("0") if not target.guild_permissions.administrator: # Message the user, informing them of their fate await interaction.response.defer() diff --git a/src/bot/cogs/verification/verification_dropdown.py b/src/bot/cogs/verification/verification_dropdown.py index 7df09b7..6b5604d 100644 --- a/src/bot/cogs/verification/verification_dropdown.py +++ b/src/bot/cogs/verification/verification_dropdown.py @@ -122,9 +122,11 @@ def __init__(self, bot): async def verify(self, ctx): """Command to verify yourself.""" - if str(type(ctx.channel)) == "": - await ctx.respond( - f"You need to use the command in the {self.bot.get_channel(self.verification_channel).mention} channel." + if isinstance(ctx.channel, discord.DMChannel): + verification_channel = self.bot.get_channel(int(self.verification_channel)) + await ctx.send( + f"You need to use the command in the " + f"{verification_channel.mention if verification_channel else 'verification'} channel." ) return diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index e2d2c3a..ee804c6 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -31,6 +31,7 @@ async def log_unverified_join(self, member, logging_channel): await logging_channel.send(f"<@{member.id}> joined, but has not verified.") async def send_welcome_message(self, guild, member): + verification_channel = self.bot.get_channel(int(self.verification_channel)) welcome_message = f""" Hi there, {member.mention} I'm Zorak, the moderator of {guild.name}. @@ -38,7 +39,7 @@ async def send_welcome_message(self, guild, member): We are very happy that you have decided to join us. Before you are allowed to chat, you need to verify that you are NOT a bot.\n Dont worry... it's easy. - Just go to {self.bot.get_channel(self.verification_log) if self.verification_log is not None else "the verification channel"} + Just go to {verification_channel.mention if verification_channel else "the verification channel"} and use the **{os.getenv("PREFIX")}verify** command. After you do, all of {guild.name} is available to you. Have a great time :-)