Compare commits
3 commits
743949e9ad
...
615bf62d8b
Author | SHA1 | Date | |
---|---|---|---|
615bf62d8b | |||
0a33858027 | |||
fb58c01a81 |
1 changed files with 50 additions and 51 deletions
|
@ -1,8 +1,7 @@
|
||||||
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, modlog
|
from redbot.core import Config, commands, app_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."""
|
||||||
|
@ -115,56 +114,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:
|
||||||
current_list.remove(channel.id)
|
await ctx.send("This channel is already in the logging channel list!")
|
||||||
await self.config.guild(ctx.guild.id).logging_channels.set(current_list)
|
return
|
||||||
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.")
|
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='dm')
|
@shortmute_config.command(name='removechannel')
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def shortmute_config_dm(self, ctx: commands.Context, enabled: bool = None):
|
async def shortmute_config_removechannel(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||||
"""This command changes if the `/shortmute` slash command Direct Messages its target."""
|
"""This command removes a channel from the `/shortmute`slash command's logging channels list."""
|
||||||
old_value = await self.config.guild(ctx.guild.id).dm()
|
current_list = await self.config.guild(ctx.guild.id).logging_channels()
|
||||||
if enabled:
|
if channel.id in current_list:
|
||||||
await self.config.guild(ctx.guild.id).dm.set(enabled)
|
current_list.remove(channel.id)
|
||||||
await ctx.send(content=f"Shortmute Direct Message setting changed!\nOld value: `{old_value}`\nNew value: `{enabled}`")
|
await self.config.guild(ctx.guild.id).logging_channels.set(current_list)
|
||||||
elif old_value is True:
|
await ctx.send(f"{channel.mention} has been removed from the logging channels list.")
|
||||||
await ctx.send(content="Shortmute Direct Messages are currently enabled!")
|
else:
|
||||||
elif old_value is False:
|
await ctx.send("Please provide a valid channel that exists in the logging channels list.")
|
||||||
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