fix(antipolls): ruff fixes
This commit is contained in:
parent
59d33ea87d
commit
d51e3f17e9
2 changed files with 12 additions and 12 deletions
|
@ -17,7 +17,7 @@ class AntiPolls(commands.Cog):
|
||||||
|
|
||||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||||
__version__ = "1.0.1"
|
__version__ = "1.0.2"
|
||||||
__documentation__ = "https://seacogs.coastalcommits.com/antipolls/"
|
__documentation__ = "https://seacogs.coastalcommits.com/antipolls/"
|
||||||
|
|
||||||
def __init__(self, bot: Red):
|
def __init__(self, bot: Red):
|
||||||
|
@ -45,11 +45,11 @@ class AntiPolls(commands.Cog):
|
||||||
]
|
]
|
||||||
return "\n".join(text)
|
return "\n".join(text)
|
||||||
|
|
||||||
async def red_delete_data_for_user(self, **kwargs): # pylint: disable=unused-argument
|
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 polls_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")
|
||||||
|
@ -62,13 +62,13 @@ class AntiPolls(commands.Cog):
|
||||||
|
|
||||||
guild_config = await self.config.guild(message.guild).all()
|
guild_config = await self.config.guild(message.guild).all()
|
||||||
|
|
||||||
if guild_config['manage_messages'] is True and message.author.guild_permissions.manage_messages:
|
if guild_config["manage_messages"] is True and message.author.guild_permissions.manage_messages:
|
||||||
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("Message in whitelisted channel %s ignored", message.channel.id)
|
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("Message from whitelisted role %s ignored", message.author.roles)
|
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:
|
||||||
|
@ -80,7 +80,7 @@ class AntiPolls(commands.Cog):
|
||||||
return self.logger.error("Failed to delete message: %s", e)
|
return self.logger.error("Failed to delete message: %s", e)
|
||||||
|
|
||||||
return self.logger.trace("Deleted poll message %s", message.id)
|
return self.logger.trace("Deleted poll message %s", message.id)
|
||||||
self.logger.verbose("Message %s is not a poll, ignoring", message.id)
|
return 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()
|
||||||
|
@ -123,13 +123,13 @@ class AntiPolls(commands.Cog):
|
||||||
await ctx.send(f"The following roles were not in the whitelist: {humanize_list([role.mention for role in failed])}", delete_after=10)
|
await ctx.send(f"The following roles were not in the whitelist: {humanize_list([role.mention for role in failed])}", delete_after=10)
|
||||||
|
|
||||||
@antipolls_roles.command(name="list")
|
@antipolls_roles.command(name="list")
|
||||||
async def antipolls_roles_list(self, ctx: commands.Context) -> None:
|
async def antipolls_roles_list(self, ctx: commands.Context) -> discord.Message:
|
||||||
"""List roles in the whitelist."""
|
"""List roles in the whitelist."""
|
||||||
role_whitelist = await self.config.guild(ctx.guild).role_whitelist()
|
role_whitelist = await self.config.guild(ctx.guild).role_whitelist()
|
||||||
if not role_whitelist:
|
if not role_whitelist:
|
||||||
return await ctx.send("No roles in the whitelist.")
|
return await ctx.send("No roles in the whitelist.")
|
||||||
roles = [ctx.guild.get_role(role) for role in role_whitelist]
|
roles = [ctx.guild.get_role(role) for role in role_whitelist]
|
||||||
await ctx.send(humanize_list([role.mention for role in roles]))
|
return await ctx.send(humanize_list([role.mention for role in roles]))
|
||||||
|
|
||||||
@antipolls.group(name="channels")
|
@antipolls.group(name="channels")
|
||||||
async def antipolls_channels(self, ctx: commands.Context) -> None:
|
async def antipolls_channels(self, ctx: commands.Context) -> None:
|
||||||
|
@ -166,13 +166,13 @@ class AntiPolls(commands.Cog):
|
||||||
await ctx.send(f"The following channels were not in the whitelist: {humanize_list([channel.mention for channel in failed])}", delete_after=10)
|
await ctx.send(f"The following channels were not in the whitelist: {humanize_list([channel.mention for channel in failed])}", delete_after=10)
|
||||||
|
|
||||||
@antipolls_channels.command(name="list")
|
@antipolls_channels.command(name="list")
|
||||||
async def antipolls_channels_list(self, ctx: commands.Context) -> None:
|
async def antipolls_channels_list(self, ctx: commands.Context) -> discord.Message:
|
||||||
"""List channels in the whitelist."""
|
"""List channels in the whitelist."""
|
||||||
channel_whitelist = await self.config.guild(ctx.guild).channel_whitelist()
|
channel_whitelist = await self.config.guild(ctx.guild).channel_whitelist()
|
||||||
if not channel_whitelist:
|
if not channel_whitelist:
|
||||||
return await ctx.send("No channels in the whitelist.")
|
return await ctx.send("No channels in the whitelist.")
|
||||||
channels = [ctx.guild.get_channel(channel) for channel in channel_whitelist]
|
channels = [ctx.guild.get_channel(channel) for channel in channel_whitelist]
|
||||||
await ctx.send(humanize_list([channel.mention for channel in channels]))
|
return await ctx.send(humanize_list([channel.mention for channel in channels]))
|
||||||
|
|
||||||
@antipolls.command(name="managemessages")
|
@antipolls.command(name="managemessages")
|
||||||
async def antipolls_managemessages(self, ctx: commands.Context, enabled: bool) -> None:
|
async def antipolls_managemessages(self, ctx: commands.Context, enabled: bool) -> None:
|
||||||
|
|
|
@ -105,7 +105,7 @@ select = [
|
||||||
"RET",
|
"RET",
|
||||||
"RSE",
|
"RSE",
|
||||||
]
|
]
|
||||||
ignore = ["PLR0912", "PLR0915", "PLR2004", "PLR0913", "EM101"]
|
ignore = ["PLR0911", "PLR0912", "PLR0915", "PLR2004", "PLR0913", "EM101"]
|
||||||
|
|
||||||
# Allow fix for all enabled rules (when `--fix`) is provided.
|
# Allow fix for all enabled rules (when `--fix`) is provided.
|
||||||
fixable = ["ALL"]
|
fixable = ["ALL"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue