This commit is contained in:
parent
2b84f05eac
commit
223b915d2d
1 changed files with 14 additions and 17 deletions
|
@ -1,8 +1,8 @@
|
|||
import discord
|
||||
from pytimeparse2 import disable_dateutil, parse
|
||||
from discord import ui
|
||||
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):
|
||||
"""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:
|
||||
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
|
||||
elif evidence_link:
|
||||
if evidence_link:
|
||||
evidence = evidence_link
|
||||
elif evidence_image:
|
||||
evidence = str(evidence_image)
|
||||
|
@ -70,7 +70,7 @@ class Shortmute(commands.Cog):
|
|||
if role in target.roles:
|
||||
await interaction.response.send_message(content="You're trying to shortmute someone who is immune from shortmuting.", ephemeral=True)
|
||||
return
|
||||
if duration == 1 or duration == -1:
|
||||
if duration in (1, -1):
|
||||
readable_duration = f"{duration} minute"
|
||||
else:
|
||||
readable_duration = f"{duration} minutes"
|
||||
|
@ -80,7 +80,7 @@ class Shortmute(commands.Cog):
|
|||
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)
|
||||
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)
|
||||
return
|
||||
if skip_confirmation is False:
|
||||
|
@ -104,7 +104,7 @@ class Shortmute(commands.Cog):
|
|||
dm_embed.set_image(url=evidence)
|
||||
try:
|
||||
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.")
|
||||
logging_channels_list = await self.config.guild(interaction.guild).logging_channels()
|
||||
if logging_channels_list:
|
||||
|
@ -124,12 +124,12 @@ class Shortmute(commands.Cog):
|
|||
self.config = Config.get_conf(None, cog_name='Shortmute', identifier=25781647388294)
|
||||
|
||||
@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()
|
||||
target = self.passed_info['target']
|
||||
target: discord.Member = self.passed_info['target']
|
||||
readable_duration = self.passed_info['readable_duration']
|
||||
reason = self.passed_info['reason']
|
||||
old_interaction = self.passed_info['interaction']
|
||||
reason: str = self.passed_info['reason']
|
||||
old_interaction: discord.Interaction = self.passed_info['interaction']
|
||||
color = self.passed_info['color']
|
||||
timedelta = self.passed_info['timedelta']
|
||||
evidence = self.passed_info['evidence']
|
||||
|
@ -146,7 +146,7 @@ class Shortmute(commands.Cog):
|
|||
dm_embed.set_image(url=evidence)
|
||||
try:
|
||||
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.")
|
||||
logging_channels_list = await self.config.guild(old_interaction.guild).logging_channels()
|
||||
if logging_channels_list:
|
||||
|
@ -159,8 +159,8 @@ class Shortmute(commands.Cog):
|
|||
await channel_obj.send(embed=logging_embed)
|
||||
|
||||
@ui.button(label="No", style=discord.ButtonStyle.danger)
|
||||
async def shortmute_button_no(self, button: ui.Button, interaction: discord.Interaction):
|
||||
message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None)
|
||||
async def shortmute_button_no(self, button: ui.Button, interaction: discord.Interaction): # pylint: disable=arguments-differ
|
||||
message: discord.Message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None)
|
||||
await message.delete(delay=3)
|
||||
|
||||
@commands.group(name='shortmuteset', autohelp=True)
|
||||
|
@ -190,11 +190,10 @@ class Shortmute(commands.Cog):
|
|||
@commands.admin()
|
||||
async def shortmute_config_channel_add(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||
"""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.id in current_list:
|
||||
await ctx.send("This channel is already in the logging channel list!")
|
||||
return
|
||||
else:
|
||||
current_list.append(channel.id)
|
||||
await self.config.guild(ctx.guild).logging_channels.set(current_list)
|
||||
|
@ -240,7 +239,6 @@ class Shortmute(commands.Cog):
|
|||
if role:
|
||||
if role.id in current_list:
|
||||
await ctx.send("This role is already in the immune roles list!")
|
||||
return
|
||||
else:
|
||||
current_list.append(role.id)
|
||||
await self.config.guild(ctx.guild).immune_roles.set(current_list)
|
||||
|
@ -286,7 +284,6 @@ class Shortmute(commands.Cog):
|
|||
if user:
|
||||
if user.id in current_list:
|
||||
await ctx.send("That user is already in the blacklisted users list!")
|
||||
return
|
||||
else:
|
||||
current_list.append(user.id)
|
||||
await self.config.guild(ctx.guild).blacklisted_users.set(current_list)
|
||||
|
|
Loading…
Reference in a new issue