fix(shortmute): pylint fixes
Some checks failed
Pylint / Pylint (push) Failing after 1m7s

This commit is contained in:
Seaswimmer 2023-09-24 20:43:26 -04:00
parent 2b84f05eac
commit 223b915d2d
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -1,8 +1,8 @@
import discord import discord
from pytimeparse2 import disable_dateutil, parse
from discord import ui from discord import ui
from discord.ext.commands import Bot from discord.ext.commands import Bot
from redbot.core import Config, commands, app_commands from pytimeparse2 import disable_dateutil, parse
from redbot.core import Config, app_commands, commands
class Shortmute(commands.Cog): class Shortmute(commands.Cog):
"""Allows staff members to shortmute individuals for up to 30 minutes, using Discord's Timeouts feature.""" """Allows staff members to shortmute individuals for up to 30 minutes, using Discord's Timeouts feature."""
@ -43,7 +43,7 @@ class Shortmute(commands.Cog):
if evidence_image and evidence_link: if evidence_image and evidence_link:
await interaction.response.send_message(content="You've provided both the `evidence_image` and the `evidence_link` arguments! Please only use one or the other.", ephemeral=True) await interaction.response.send_message(content="You've provided both the `evidence_image` and the `evidence_link` arguments! Please only use one or the other.", ephemeral=True)
return return
elif evidence_link: if evidence_link:
evidence = evidence_link evidence = evidence_link
elif evidence_image: elif evidence_image:
evidence = str(evidence_image) evidence = str(evidence_image)
@ -70,7 +70,7 @@ class Shortmute(commands.Cog):
if role in target.roles: if role in target.roles:
await interaction.response.send_message(content="You're trying to shortmute someone who is immune from shortmuting.", ephemeral=True) await interaction.response.send_message(content="You're trying to shortmute someone who is immune from shortmuting.", ephemeral=True)
return return
if duration == 1 or duration == -1: if duration in (1, -1):
readable_duration = f"{duration} minute" readable_duration = f"{duration} minute"
else: else:
readable_duration = f"{duration} minutes" readable_duration = f"{duration} minutes"
@ -80,7 +80,7 @@ class Shortmute(commands.Cog):
if duration > 30: if duration > 30:
await interaction.response.send_message(content=f"{readable_duration} is longer than the 30 minutes you are allowed to shortmute users for.", ephemeral=True) await interaction.response.send_message(content=f"{readable_duration} is longer than the 30 minutes you are allowed to shortmute users for.", ephemeral=True)
return return
elif duration < 1: if duration < 1:
await interaction.response.send_message(content=f"Please shortmute the user for longer than {readable_duration}! The maximum duration is 30 minutes.", ephemeral=True) await interaction.response.send_message(content=f"Please shortmute the user for longer than {readable_duration}! The maximum duration is 30 minutes.", ephemeral=True)
return return
if skip_confirmation is False: if skip_confirmation is False:
@ -104,7 +104,7 @@ class Shortmute(commands.Cog):
dm_embed.set_image(url=evidence) dm_embed.set_image(url=evidence)
try: try:
await target.send(embed=dm_embed) await target.send(embed=dm_embed)
except discord.HTTPException as error: except discord.HTTPException:
await message.edit(content="Could not message the target, user most likely has Direct Messages disabled.") await message.edit(content="Could not message the target, user most likely has Direct Messages disabled.")
logging_channels_list = await self.config.guild(interaction.guild).logging_channels() logging_channels_list = await self.config.guild(interaction.guild).logging_channels()
if logging_channels_list: if logging_channels_list:
@ -124,12 +124,12 @@ class Shortmute(commands.Cog):
self.config = Config.get_conf(None, cog_name='Shortmute', identifier=25781647388294) self.config = Config.get_conf(None, cog_name='Shortmute', identifier=25781647388294)
@ui.button(label="Yes", style=discord.ButtonStyle.success) @ui.button(label="Yes", style=discord.ButtonStyle.success)
async def shortmute_button_yes(self, button: ui.Button, interaction: discord.Interaction): async def shortmute_button_yes(self, button: ui.Button, interaction: discord.Interaction): # pylint: disable=arguments-differ
disable_dateutil() disable_dateutil()
target = self.passed_info['target'] target: discord.Member = self.passed_info['target']
readable_duration = self.passed_info['readable_duration'] readable_duration = self.passed_info['readable_duration']
reason = self.passed_info['reason'] reason: str = self.passed_info['reason']
old_interaction = self.passed_info['interaction'] old_interaction: discord.Interaction = self.passed_info['interaction']
color = self.passed_info['color'] color = self.passed_info['color']
timedelta = self.passed_info['timedelta'] timedelta = self.passed_info['timedelta']
evidence = self.passed_info['evidence'] evidence = self.passed_info['evidence']
@ -146,7 +146,7 @@ class Shortmute(commands.Cog):
dm_embed.set_image(url=evidence) dm_embed.set_image(url=evidence)
try: try:
await target.send(embed=dm_embed) await target.send(embed=dm_embed)
except discord.HTTPException as error: except discord.HTTPException:
await old_message.edit(content="Could not message the target, user most likely has Direct Messages disabled.") await old_message.edit(content="Could not message the target, user most likely has Direct Messages disabled.")
logging_channels_list = await self.config.guild(old_interaction.guild).logging_channels() logging_channels_list = await self.config.guild(old_interaction.guild).logging_channels()
if logging_channels_list: if logging_channels_list:
@ -159,8 +159,8 @@ class Shortmute(commands.Cog):
await channel_obj.send(embed=logging_embed) await channel_obj.send(embed=logging_embed)
@ui.button(label="No", style=discord.ButtonStyle.danger) @ui.button(label="No", style=discord.ButtonStyle.danger)
async def shortmute_button_no(self, button: ui.Button, interaction: discord.Interaction): async def shortmute_button_no(self, button: ui.Button, interaction: discord.Interaction): # pylint: disable=arguments-differ
message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None) message: discord.Message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None)
await message.delete(delay=3) await message.delete(delay=3)
@commands.group(name='shortmuteset', autohelp=True) @commands.group(name='shortmuteset', autohelp=True)
@ -190,11 +190,10 @@ class Shortmute(commands.Cog):
@commands.admin() @commands.admin()
async def shortmute_config_channel_add(self, ctx: commands.Context, channel: discord.TextChannel = None): async def shortmute_config_channel_add(self, ctx: commands.Context, channel: discord.TextChannel = None):
"""Adds a channel to the logging channels list.""" """Adds a channel to the logging channels list."""
current_list = await self.config.guild(ctx.guild).logging_channels() current_list: list = await self.config.guild(ctx.guild).logging_channels()
if channel: if channel:
if channel.id in current_list: if channel.id in current_list:
await ctx.send("This channel is already in the logging channel list!") await ctx.send("This channel is already in the logging channel list!")
return
else: else:
current_list.append(channel.id) current_list.append(channel.id)
await self.config.guild(ctx.guild).logging_channels.set(current_list) await self.config.guild(ctx.guild).logging_channels.set(current_list)
@ -240,7 +239,6 @@ class Shortmute(commands.Cog):
if role: if role:
if role.id in current_list: if role.id in current_list:
await ctx.send("This role is already in the immune roles list!") await ctx.send("This role is already in the immune roles list!")
return
else: else:
current_list.append(role.id) current_list.append(role.id)
await self.config.guild(ctx.guild).immune_roles.set(current_list) await self.config.guild(ctx.guild).immune_roles.set(current_list)
@ -286,7 +284,6 @@ class Shortmute(commands.Cog):
if user: if user:
if user.id in current_list: if user.id in current_list:
await ctx.send("That user is already in the blacklisted users list!") await ctx.send("That user is already in the blacklisted users list!")
return
else: else:
current_list.append(user.id) current_list.append(user.id)
await self.config.guild(ctx.guild).blacklisted_users.set(current_list) await self.config.guild(ctx.guild).blacklisted_users.set(current_list)