fix(antipolls): pylint fixes
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 36s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 52s

This commit is contained in:
Seaswimmer 2024-04-16 12:38:00 -04:00
parent aaf9ac1b4e
commit d17a7e645f
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -44,12 +44,12 @@ class AntiPolls(commands.Cog):
] ]
return "\n".join(text) return "\n".join(text)
async def red_delete_data_for_user(self, **kwargs): async def red_delete_data_for_user(self, **kwargs): # pylint: disable=unused-argument
"""Nothing to delete.""" """Nothing to delete."""
return return
@commands.Cog.listener('on_message') @commands.Cog.listener('on_message')
async def listener(self, message: discord.Message) -> None: async def polls_listener(self, message: discord.Message) -> None:
if message.guild is None: if message.guild is None:
return self.logger.verbose("Message in direct messages ignored") return self.logger.verbose("Message in direct messages ignored")
@ -57,7 +57,7 @@ class AntiPolls(commands.Cog):
return self.logger.verbose("Message from bot ignored") return self.logger.verbose("Message from bot ignored")
if await self.bot.cog_disabled_in_guild(self, message.guild): if await self.bot.cog_disabled_in_guild(self, message.guild):
return self.logger.verbose(f"Message ignored, cog is disabled in guild {message.guild.id}") return self.logger.verbose("Message ignored, cog is disabled in guild %s", message.guild.id)
guild_config = await self.config.guild(message.guild).all() guild_config = await self.config.guild(message.guild).all()
@ -65,21 +65,21 @@ class AntiPolls(commands.Cog):
return self.logger.verbose("Message from user with Manage Messages permission ignored") return self.logger.verbose("Message from user with Manage Messages permission ignored")
if message.channel.id in guild_config['channel_whitelist']: if message.channel.id in guild_config['channel_whitelist']:
return self.logger.verbose(f"Message in whitelisted channel {message.channel.id} ignored") return self.logger.verbose("Message in whitelisted channel %s ignored", message.channel.id)
if any(role.id in guild_config['role_whitelist'] for role in message.author.roles): if any(role.id in guild_config['role_whitelist'] for role in message.author.roles):
return self.logger.verbose(f"Message from whitelisted role {message.author.roles} ignored") return self.logger.verbose("Message from whitelisted role %s ignored", message.author.roles)
if not message.content and not message.embeds and not message.attachments and not message.stickers: if not message.content and not message.embeds and not message.attachments and not message.stickers:
self.logger.trace(f"Message {message.id} is a poll, attempting to delete") self.logger.trace("Message %s is a poll, attempting to delete", message.id)
try: try:
await message.delete() await message.delete()
except discord.HTTPException as e: except discord.HTTPException as e:
return self.logger.error(f"Failed to delete message: {e}") return self.logger.error("Failed to delete message: %s", e)
return self.logger.trace(f"Deleted poll message {message.id}") return self.logger.trace("Deleted poll message %s", message.id)
self.logger.verbose(f"Message {message.id} is not a poll, ignoring") self.logger.verbose("Message %s is not a poll, ignoring", message.id)
@commands.group(name="antipolls", aliases=["ap"]) @commands.group(name="antipolls", aliases=["ap"])
@commands.guild_only() @commands.guild_only()
@ -99,12 +99,12 @@ class AntiPolls(commands.Cog):
failed: list[discord.Role] = [] failed: list[discord.Role] = []
for role in roles: for role in roles:
if role.id in role_whitelist: if role.id in role_whitelist:
failed.append(role.mention) failed.append(role)
continue continue
role_whitelist.append(role.id) role_whitelist.append(role.id)
await ctx.tick() await ctx.tick()
if failed: if failed:
await ctx.send(f"The following roles were already in the whitelist: {humanize_list([role for role in failed])}", delete_after=10) await ctx.send(f"The following roles were already in the whitelist: {humanize_list([role.mention for role in failed])}", delete_after=10)
@antipolls_roles.command(name="remove") @antipolls_roles.command(name="remove")
async def antipolls_roles_remove(self, ctx: commands.Context, *roles: discord.Role) -> None: async def antipolls_roles_remove(self, ctx: commands.Context, *roles: discord.Role) -> None: