Compare commits
No commits in common. "615bf62d8b5bae3df05bb30bdd566fd7cb794250" and "743949e9ad2289f8473b84d937c288a47a81d38f" have entirely different histories.
615bf62d8b
...
743949e9ad
1 changed files with 50 additions and 49 deletions
|
@ -1,7 +1,8 @@
|
||||||
|
from datetime import datetime
|
||||||
import discord
|
import discord
|
||||||
from pytimeparse2 import disable_dateutil, parse
|
from pytimeparse2 import disable_dateutil, parse
|
||||||
from discord import ui
|
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):
|
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."""
|
||||||
|
@ -114,56 +115,56 @@ class Shortmute(commands.Cog):
|
||||||
message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None)
|
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)
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
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()
|
||||||
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.id).logging_channels()
|
||||||
if channel:
|
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:
|
if channel.id in current_list:
|
||||||
await ctx.send("This channel is already in the logging channel list!")
|
current_list.remove(channel.id)
|
||||||
return
|
|
||||||
else:
|
|
||||||
current_list.append(channel.id)
|
|
||||||
await self.config.guild(ctx.guild.id).logging_channels.set(current_list)
|
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.")
|
await ctx.send(f"{channel.mention} has been removed from 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:
|
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')
|
@shortmute_config.command(name='dm')
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def shortmute_config_removechannel(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
async def shortmute_config_dm(self, ctx: commands.Context, enabled: bool = None):
|
||||||
"""This command removes a channel from the `/shortmute`slash command's logging channels list."""
|
"""This command changes if the `/shortmute` slash command Direct Messages its target."""
|
||||||
current_list = await self.config.guild(ctx.guild.id).logging_channels()
|
old_value = await self.config.guild(ctx.guild.id).dm()
|
||||||
if channel.id in current_list:
|
if enabled:
|
||||||
current_list.remove(channel.id)
|
await self.config.guild(ctx.guild.id).dm.set(enabled)
|
||||||
await self.config.guild(ctx.guild.id).logging_channels.set(current_list)
|
await ctx.send(content=f"Shortmute Direct Message setting changed!\nOld value: `{old_value}`\nNew value: `{enabled}`")
|
||||||
await ctx.send(f"{channel.mention} has been removed from the logging channels list.")
|
elif old_value is True:
|
||||||
else:
|
await ctx.send(content="Shortmute Direct Messages are currently enabled!")
|
||||||
await ctx.send("Please provide a valid channel that exists in the logging channels list.")
|
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!")
|
|
||||||
|
|
Loading…
Reference in a new issue