Compare commits
3 commits
615bf62d8b
...
1d64001ae2
Author | SHA1 | Date | |
---|---|---|---|
1d64001ae2 | |||
79fb4ce9ec | |||
672e7c2936 |
1 changed files with 59 additions and 10 deletions
|
@ -11,7 +11,8 @@ class Shortmute(commands.Cog):
|
||||||
self.config = Config.get_conf(self, identifier=25781647388294, force_registration=True)
|
self.config = Config.get_conf(self, identifier=25781647388294, force_registration=True)
|
||||||
self.config.register_guild(
|
self.config.register_guild(
|
||||||
dm = True,
|
dm = True,
|
||||||
logging_channels = []
|
logging_channels = [],
|
||||||
|
immune_roles = []
|
||||||
)
|
)
|
||||||
|
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
|
@ -39,12 +40,18 @@ class Shortmute(commands.Cog):
|
||||||
"interaction": interaction
|
"interaction": interaction
|
||||||
}
|
}
|
||||||
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.")
|
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:
|
elif evidence_link:
|
||||||
evidence = evidence_link
|
evidence = evidence_link
|
||||||
elif evidence_image:
|
elif evidence_image:
|
||||||
evidence = str(evidence_image)
|
evidence = str(evidence_image)
|
||||||
|
immune_roles_list = await self.config.guild(interaction.guild).immune_roles()
|
||||||
|
for role_id in immune_roles_list:
|
||||||
|
role = interaction.guild.get_role(role_id)
|
||||||
|
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 == 1 or duration == -1:
|
||||||
readable_duration = f"{duration} minute"
|
readable_duration = f"{duration} minute"
|
||||||
passed_info.update({
|
passed_info.update({
|
||||||
|
@ -92,7 +99,7 @@ class Shortmute(commands.Cog):
|
||||||
old_message = await old_interaction.edit_original_response(embed=edit_embed, view=None)
|
old_message = await old_interaction.edit_original_response(embed=edit_embed, view=None)
|
||||||
await target.timeout(until=timedelta, reason=f"User shortmuted for {readable_duration} by {old_interaction.user.name} ({old_interaction.user.id}) for: {reason}")
|
await target.timeout(until=timedelta, reason=f"User shortmuted for {readable_duration} by {old_interaction.user.name} ({old_interaction.user.id}) for: {reason}")
|
||||||
await interaction.response.send_message(content=f"{target.mention} shortmuted for {readable_duration} by {old_interaction.user.mention} for: `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} shortmuted for {readable_duration} by {old_interaction.user.mention} for: `{reason}`")
|
||||||
if await self.config.guild(old_interaction.guild_id).dm() is True:
|
if await self.config.guild(old_interaction.guild).dm() is True:
|
||||||
dm_embed = discord.Embed(title=f"You've been shortmuted in {old_interaction.guild.name}!", description=f"Moderator: {old_interaction.user.mention}\nTarget: {target.mention}\nDuration: `{readable_duration}`\nReason: `{reason}`", color=await self.bot.get_embed_color(None))
|
dm_embed = discord.Embed(title=f"You've been shortmuted in {old_interaction.guild.name}!", description=f"Moderator: {old_interaction.user.mention}\nTarget: {target.mention}\nDuration: `{readable_duration}`\nReason: `{reason}`", color=await self.bot.get_embed_color(None))
|
||||||
if evidence:
|
if evidence:
|
||||||
dm_embed.set_image(evidence)
|
dm_embed.set_image(evidence)
|
||||||
|
@ -100,7 +107,7 @@ class Shortmute(commands.Cog):
|
||||||
await target.send(embed=dm_embed)
|
await target.send(embed=dm_embed)
|
||||||
except discord.HTTPException as error:
|
except discord.HTTPException as error:
|
||||||
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.id).logging_channels()
|
logging_channels_list = await self.config.guild(old_interaction.guild).logging_channels()
|
||||||
if logging_channels_list:
|
if logging_channels_list:
|
||||||
logging_embed = discord.Embed(title="Shortmute", description=f"Moderator: {old_interaction.user.mention} ({old_interaction.user.id})\nTarget: {target.mention} ({target.id})\nDuration: `{readable_duration}`\nReason: `{reason}`", color=await self.bot.get_embed_color(None))
|
logging_embed = discord.Embed(title="Shortmute", description=f"Moderator: {old_interaction.user.mention} ({old_interaction.user.id})\nTarget: {target.mention} ({target.id})\nDuration: `{readable_duration}`\nReason: `{reason}`", color=await self.bot.get_embed_color(None))
|
||||||
if evidence:
|
if evidence:
|
||||||
|
@ -116,21 +123,23 @@ class Shortmute(commands.Cog):
|
||||||
|
|
||||||
@commands.group(name='shortmuteset', autohelp=True)
|
@commands.group(name='shortmuteset', autohelp=True)
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
@commands.admin()
|
||||||
async def shortmute_config(self, ctx: commands.Context):
|
async def shortmute_config(self, ctx: commands.Context):
|
||||||
"""This command group is used to configure the `/shortmute` slash command."""
|
"""This command group is used to configure the `/shortmute` slash command."""
|
||||||
|
|
||||||
@shortmute_config.command(name='addchannel')
|
@shortmute_config.command(name='addchannel')
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
@commands.admin()
|
||||||
async def shortmute_config_addchannel(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
async def shortmute_config_addchannel(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||||
"""This command changes where the `/shortmute` slash command will log shortmutes. You can set multiple channels as well!"""
|
"""This command changes where the `/shortmute` slash command will log shortmutes. You can set multiple channels as well!"""
|
||||||
current_list = await self.config.guild(ctx.guild.id).logging_channels()
|
current_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
|
return
|
||||||
else:
|
else:
|
||||||
current_list.append(channel.id)
|
current_list.append(channel.id)
|
||||||
await self.config.guild(ctx.guild.id).logging_channels.set(current_list)
|
await self.config.guild(ctx.guild).logging_channels.set(current_list)
|
||||||
await ctx.send(f"{channel.mention} has been added to the logging channels list.")
|
await ctx.send(f"{channel.mention} has been added to the logging channels list.")
|
||||||
else:
|
else:
|
||||||
already_in_list = []
|
already_in_list = []
|
||||||
|
@ -145,23 +154,63 @@ class Shortmute(commands.Cog):
|
||||||
|
|
||||||
@shortmute_config.command(name='removechannel')
|
@shortmute_config.command(name='removechannel')
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
@commands.admin()
|
||||||
async def shortmute_config_removechannel(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
async def shortmute_config_removechannel(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||||
"""This command removes a channel from the `/shortmute`slash command's logging channels list."""
|
"""This command removes a channel from the `/shortmute`slash command's logging channels list."""
|
||||||
current_list = await self.config.guild(ctx.guild.id).logging_channels()
|
current_list = await self.config.guild(ctx.guild).logging_channels()
|
||||||
if channel.id in current_list:
|
if channel.id in current_list:
|
||||||
current_list.remove(channel.id)
|
current_list.remove(channel.id)
|
||||||
await self.config.guild(ctx.guild.id).logging_channels.set(current_list)
|
await self.config.guild(ctx.guild).logging_channels.set(current_list)
|
||||||
await ctx.send(f"{channel.mention} has been removed from the logging channels list.")
|
await ctx.send(f"{channel.mention} has been removed from the logging channels list.")
|
||||||
else:
|
else:
|
||||||
await ctx.send("Please provide a valid channel that exists in the logging channels list.")
|
await ctx.send("Please provide a valid channel that exists in the logging channels list.")
|
||||||
|
|
||||||
|
@shortmute_config.command(name='addrole')
|
||||||
|
@commands.guild_only()
|
||||||
|
@commands.admin()
|
||||||
|
async def shortmute_config_addrole(self, ctx: commands.Context, role: discord.Role = None):
|
||||||
|
"""This command adds roles to the immune roles list for immunity from the the `/shortmute` slash command."""
|
||||||
|
current_list = await self.config.guild(ctx.guild).immune_roles()
|
||||||
|
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)
|
||||||
|
await ctx.send(f"{role.mention} has been added to the logging channels list.", allowed_mentions = discord.AllowedMentions(roles=False))
|
||||||
|
else:
|
||||||
|
already_in_list = []
|
||||||
|
for role_id in current_list:
|
||||||
|
role_obj = ctx.guild.get_role(role_id)
|
||||||
|
if role_obj:
|
||||||
|
already_in_list.append(role_obj.mention)
|
||||||
|
if already_in_list:
|
||||||
|
await ctx.send("Roles already in the immune roles list:\n" + "\n".join(already_in_list), allowed_mentions = discord.AllowedMentions(roles=False))
|
||||||
|
else:
|
||||||
|
await ctx.send("Please provide a valid role.")
|
||||||
|
|
||||||
|
@shortmute_config.command(name='removerole')
|
||||||
|
@commands.guild_only()
|
||||||
|
@commands.admin()
|
||||||
|
async def shortmute_config_removerole(self, ctx: commands.Context, role: discord.Role = None):
|
||||||
|
"""This command removes roles from the immune roles list to remove immunity from the the `/shortmute` slash command."""
|
||||||
|
current_list = await self.config.guild(ctx.guild).immune_roles()
|
||||||
|
if role.id in current_list:
|
||||||
|
current_list.remove(role.id)
|
||||||
|
await self.config.guild(ctx.guild).immune_roles.set(current_list)
|
||||||
|
await ctx.send(f"{role.mention} has been removed from the immune roles list.", allowed_mentions = discord.AllowedMentions(roles=False))
|
||||||
|
else:
|
||||||
|
await ctx.send("Please provide a valid role that exists in the immune roles list.")
|
||||||
|
|
||||||
@shortmute_config.command(name='dm')
|
@shortmute_config.command(name='dm')
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
@commands.admin()
|
||||||
async def shortmute_config_dm(self, ctx: commands.Context, enabled: bool = None):
|
async def shortmute_config_dm(self, ctx: commands.Context, enabled: bool = None):
|
||||||
"""This command changes if the `/shortmute` slash command Direct Messages its target."""
|
"""This command changes if the `/shortmute` slash command Direct Messages its target."""
|
||||||
old_value = await self.config.guild(ctx.guild.id).dm()
|
old_value = await self.config.guild(ctx.guild).dm()
|
||||||
if enabled:
|
if enabled:
|
||||||
await self.config.guild(ctx.guild.id).dm.set(enabled)
|
await self.config.guild(ctx.guild).dm.set(enabled)
|
||||||
await ctx.send(content=f"Shortmute Direct Message setting changed!\nOld value: `{old_value}`\nNew value: `{enabled}`")
|
await ctx.send(content=f"Shortmute Direct Message setting changed!\nOld value: `{old_value}`\nNew value: `{enabled}`")
|
||||||
elif old_value is True:
|
elif old_value is True:
|
||||||
await ctx.send(content="Shortmute Direct Messages are currently enabled!")
|
await ctx.send(content="Shortmute Direct Messages are currently enabled!")
|
||||||
|
|
Loading…
Reference in a new issue