Compare commits

..

No commits in common. "615bf62d8b5bae3df05bb30bdd566fd7cb794250" and "743949e9ad2289f8473b84d937c288a47a81d38f" have entirely different histories.

View file

@ -1,7 +1,8 @@
from datetime import datetime
import discord
from pytimeparse2 import disable_dateutil, parse
from discord import ui
from redbot.core import Config, commands, app_commands
from redbot.core import Config, commands, app_commands, modlog
class Shortmute(commands.Cog):
"""Allows staff members to shortmute individuals for up to 30 minutes, using Discord's Timeouts feature."""
@ -114,56 +115,56 @@ class Shortmute(commands.Cog):
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)
@commands.guild_only()
async def shortmute_config(self, ctx: commands.Context):
"""This command group is used to configure the `/shortmute` slash command."""
@commands.group(name='shortmuteset', autohelp=True)
@commands.guild_only()
async def shortmute_config(self, ctx: commands.Context):
"""This command group is used to configure the `/shortmute` slash command."""
@shortmute_config.command(name='addchannel')
@commands.guild_only()
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!"""
current_list = await self.config.guild(ctx.guild.id).logging_channels()
if channel:
@shortmute_config.command(name='addchannel')
@commands.guild_only()
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!"""
current_list = await self.config.guild(ctx.guild.id).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.id).logging_channels.set(current_list)
await ctx.send(f"{channel.mention} has been added to the logging channels list.")
else:
already_in_list = []
for channel_id in current_list:
channel_obj = ctx.guild.get_channel(channel_id)
if channel_obj:
already_in_list.append(channel_obj.mention)
if already_in_list:
await ctx.send("Channels already in the list:\n" + "\n".join(already_in_list))
else:
await ctx.send("Please provide a valid channel.")
@shortmute_config.command(name='removechannel')
@commands.guild_only()
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."""
current_list = await self.config.guild(ctx.guild.id).logging_channels()
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)
current_list.remove(channel.id)
await self.config.guild(ctx.guild.id).logging_channels.set(current_list)
await ctx.send(f"{channel.mention} has been added to the logging channels list.")
else:
already_in_list = []
for channel_id in current_list:
channel_obj = ctx.guild.get_channel(channel_id)
if channel_obj:
already_in_list.append(channel_obj.mention)
if already_in_list:
await ctx.send("Channels already in the list:\n" + "\n".join(already_in_list))
await ctx.send(f"{channel.mention} has been removed from the logging channels list.")
else:
await ctx.send("Please provide a valid channel.")
await ctx.send("Please provide a valid channel that exists in the logging channels list.")
@shortmute_config.command(name='removechannel')
@commands.guild_only()
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."""
current_list = await self.config.guild(ctx.guild.id).logging_channels()
if channel.id in current_list:
current_list.remove(channel.id)
await self.config.guild(ctx.guild.id).logging_channels.set(current_list)
await ctx.send(f"{channel.mention} has been removed from the logging channels list.")
else:
await ctx.send("Please provide a valid channel that exists in the logging channels list.")
@shortmute_config.command(name='dm')
@commands.guild_only()
async def shortmute_config_dm(self, ctx: commands.Context, enabled: bool = None):
"""This command changes if the `/shortmute` slash command Direct Messages its target."""
old_value = await self.config.guild(ctx.guild.id).dm()
if enabled:
await self.config.guild(ctx.guild.id).dm.set(enabled)
await ctx.send(content=f"Shortmute Direct Message setting changed!\nOld value: `{old_value}`\nNew value: `{enabled}`")
elif old_value is True:
await ctx.send(content="Shortmute Direct Messages are currently enabled!")
elif old_value is False:
await ctx.send(content="Shortmute Direct Messages are currently disabled!")
@shortmute_config.command(name='dm')
@commands.guild_only()
async def shortmute_config_dm(self, ctx: commands.Context, enabled: bool = None):
"""This command changes if the `/shortmute` slash command Direct Messages its target."""
old_value = await self.config.guild(ctx.guild.id).dm()
if enabled:
await self.config.guild(ctx.guild.id).dm.set(enabled)
await ctx.send(content=f"Shortmute Direct Message setting changed!\nOld value: `{old_value}`\nNew value: `{enabled}`")
elif old_value is True:
await ctx.send(content="Shortmute Direct Messages are currently enabled!")
elif old_value is False:
await ctx.send(content="Shortmute Direct Messages are currently disabled!")