mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
chore: ruff formatting
This commit is contained in:
@@ -25,9 +25,13 @@ class Moderation(commands.GroupCog, name="moderation"):
|
||||
embed = discord.Embed(
|
||||
title="Moderation Commands",
|
||||
description="Use `.moderation <subcommand>` or `/moderation <subcommand>`.",
|
||||
color=0x7289DA
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.add_field(
|
||||
name="Available",
|
||||
value="ban, kick, purge, warnings, archive, hackban, nick, timeout",
|
||||
inline=False,
|
||||
)
|
||||
embed.add_field(name="Available", value="ban, kick, purge, warnings, archive, hackban, nick, timeout", inline=False)
|
||||
await context.send(embed=embed)
|
||||
|
||||
async def _invoke_hybrid(self, context: Context, name: str, **kwargs):
|
||||
@@ -68,15 +72,28 @@ class Moderation(commands.GroupCog, name="moderation"):
|
||||
return results[:25]
|
||||
|
||||
@moderation_group.command(name="ban")
|
||||
async def moderation_group_ban(self, context: Context, user: discord.User, *, reason: str = "Not specified", delete_messages: str = "none"):
|
||||
await self._invoke_hybrid(context, "ban", user=user, reason=reason, delete_messages=delete_messages)
|
||||
async def moderation_group_ban(
|
||||
self,
|
||||
context: Context,
|
||||
user: discord.User,
|
||||
*,
|
||||
reason: str = "Not specified",
|
||||
delete_messages: str = "none",
|
||||
):
|
||||
await self._invoke_hybrid(
|
||||
context, "ban", user=user, reason=reason, delete_messages=delete_messages
|
||||
)
|
||||
|
||||
@moderation_group.command(name="kick")
|
||||
async def moderation_group_kick(self, context: Context, user: discord.User, *, reason: str = "Not specified"):
|
||||
async def moderation_group_kick(
|
||||
self, context: Context, user: discord.User, *, reason: str = "Not specified"
|
||||
):
|
||||
await self._invoke_hybrid(context, "kick", user=user, reason=reason)
|
||||
|
||||
@moderation_group.command(name="purge")
|
||||
async def moderation_group_purge(self, context: Context, amount: int, user: discord.Member = None):
|
||||
async def moderation_group_purge(
|
||||
self, context: Context, amount: int, user: discord.Member = None
|
||||
):
|
||||
await self._invoke_hybrid(context, "purge", amount=amount, user=user)
|
||||
|
||||
@moderation_group.command(name="warnings")
|
||||
@@ -88,45 +105,57 @@ class Moderation(commands.GroupCog, name="moderation"):
|
||||
await self._invoke_hybrid(context, "archive", limit=limit)
|
||||
|
||||
@moderation_group.command(name="hackban")
|
||||
async def moderation_group_hackban(self, context: Context, user_id: str, *, reason: str = "Not specified"):
|
||||
async def moderation_group_hackban(
|
||||
self, context: Context, user_id: str, *, reason: str = "Not specified"
|
||||
):
|
||||
await self._invoke_hybrid(context, "hackban", user_id=user_id, reason=reason)
|
||||
|
||||
@moderation_group.command(name="nick")
|
||||
async def moderation_group_nick(self, context: Context, user: discord.User, *, nickname: str = None):
|
||||
async def moderation_group_nick(
|
||||
self, context: Context, user: discord.User, *, nickname: str = None
|
||||
):
|
||||
await self._invoke_hybrid(context, "nick", user=user, nickname=nickname)
|
||||
|
||||
@moderation_group.command(name="timeout")
|
||||
async def moderation_group_timeout(self, context: Context, user: discord.User, duration: str, *, reason: str = "Not specified"):
|
||||
await self._invoke_hybrid(context, "timeout", user=user, duration=duration, reason=reason)
|
||||
async def moderation_group_timeout(
|
||||
self,
|
||||
context: Context,
|
||||
user: discord.User,
|
||||
duration: str,
|
||||
*,
|
||||
reason: str = "Not specified",
|
||||
):
|
||||
await self._invoke_hybrid(
|
||||
context, "timeout", user=user, duration=duration, reason=reason
|
||||
)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="ban",
|
||||
description="Bans a user from the server."
|
||||
)
|
||||
async def ban(self, context, user: discord.User, *, reason: str = "Not specified", delete_messages: str = "none"):
|
||||
return await ban_command()(self, context, user=user, reason=reason, delete_messages=delete_messages)
|
||||
@commands.hybrid_command(name="ban", description="Bans a user from the server.")
|
||||
async def ban(
|
||||
self,
|
||||
context,
|
||||
user: discord.User,
|
||||
*,
|
||||
reason: str = "Not specified",
|
||||
delete_messages: str = "none",
|
||||
):
|
||||
return await ban_command()(
|
||||
self, context, user=user, reason=reason, delete_messages=delete_messages
|
||||
)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="kick",
|
||||
description="Kicks a user from the server."
|
||||
)
|
||||
@commands.hybrid_command(name="kick", description="Kicks a user from the server.")
|
||||
async def kick(self, context, user: discord.User, *, reason: str = "Not specified"):
|
||||
return await kick_command()(self, context, user=user, reason=reason)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="purge",
|
||||
description="Delete a number of messages."
|
||||
)
|
||||
@commands.hybrid_command(name="purge", description="Delete a number of messages.")
|
||||
async def purge(self, context, amount: int, user: discord.Member = None):
|
||||
return await purge_command()(self, context, amount=amount, user=user)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="warnings",
|
||||
description="Manage warnings of a user on a server."
|
||||
name="warnings", description="Manage warnings of a user on a server."
|
||||
)
|
||||
async def warnings(self, context):
|
||||
return await warnings_command()(self, context)
|
||||
@@ -134,7 +163,7 @@ class Moderation(commands.GroupCog, name="moderation"):
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="archive",
|
||||
description="Archives in a text file the last messages with a chosen limit of messages."
|
||||
description="Archives in a text file the last messages with a chosen limit of messages.",
|
||||
)
|
||||
async def archive(self, context, limit: int = 10):
|
||||
return await archive_command()(self, context, limit=limit)
|
||||
@@ -142,23 +171,21 @@ class Moderation(commands.GroupCog, name="moderation"):
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="hackban",
|
||||
description="Bans a user without the user having to be in the server."
|
||||
description="Bans a user without the user having to be in the server.",
|
||||
)
|
||||
async def hackban(self, context, user_id: str, *, reason: str = "Not specified"):
|
||||
return await hackban_command()(self, context, user_id=user_id, reason=reason)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="nick",
|
||||
description="Change the nickname of a user on a server."
|
||||
name="nick", description="Change the nickname of a user on a server."
|
||||
)
|
||||
async def nick(self, context, user: discord.User, *, nickname: str = None):
|
||||
return await nick_command()(self, context, user=user, nickname=nickname)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="timeout",
|
||||
description="Timeout a user for a specified duration."
|
||||
name="timeout", description="Timeout a user for a specified duration."
|
||||
)
|
||||
@app_commands.describe(
|
||||
user="The user that should be timed out.",
|
||||
@@ -166,13 +193,23 @@ class Moderation(commands.GroupCog, name="moderation"):
|
||||
reason="The reason why the user should be timed out.",
|
||||
)
|
||||
@app_commands.autocomplete(duration=timeout_duration_autocomplete)
|
||||
async def timeout(self, context, user: discord.User, duration: str, *, reason: str = "Not specified"):
|
||||
return await timeout_command()(self, context, user=user, duration=duration, reason=reason)
|
||||
async def timeout(
|
||||
self,
|
||||
context,
|
||||
user: discord.User,
|
||||
duration: str,
|
||||
*,
|
||||
reason: str = "Not specified",
|
||||
):
|
||||
return await timeout_command()(
|
||||
self, context, user=user, duration=duration, reason=reason
|
||||
)
|
||||
|
||||
|
||||
async def setup(bot) -> None:
|
||||
cog = Moderation(bot)
|
||||
await bot.add_cog(cog)
|
||||
|
||||
|
||||
bot.logger.info("Loaded extension 'moderation.ban'")
|
||||
bot.logger.info("Loaded extension 'moderation.kick'")
|
||||
bot.logger.info("Loaded extension 'moderation.purge'")
|
||||
|
||||
@@ -23,7 +23,7 @@ def archive_command():
|
||||
:param limit: The limit of messages that should be archived. Default is 10.
|
||||
"""
|
||||
log_file = f"{context.channel.id}.log"
|
||||
|
||||
|
||||
messages = []
|
||||
async for message in context.channel.history(
|
||||
limit=limit, before=context.message
|
||||
@@ -36,10 +36,10 @@ def archive_command():
|
||||
if len(attachments) >= 1
|
||||
else ""
|
||||
)
|
||||
|
||||
|
||||
message_line = f"{message.created_at.strftime('%m/%d/%Y %H:%M:%S')} {message.author} {message.id}: {message.clean_content} {attachments_text}\n"
|
||||
messages.append(message_line)
|
||||
|
||||
|
||||
with open(log_file, "w", encoding="UTF-8") as f:
|
||||
f.write(
|
||||
f'Archived messages from: #{context.channel} ({context.channel.id}) in the guild "{context.guild}" ({context.guild.id}) at {datetime.now().strftime("%m/%d/%Y %H:%M:%S")}\n'
|
||||
@@ -47,9 +47,9 @@ def archive_command():
|
||||
|
||||
for message_line in reversed(messages):
|
||||
f.write(message_line)
|
||||
|
||||
|
||||
f = discord.File(log_file)
|
||||
await context.send(file=f)
|
||||
os.remove(log_file)
|
||||
|
||||
return archive
|
||||
|
||||
return archive
|
||||
|
||||
@@ -14,17 +14,24 @@ def ban_command():
|
||||
reason="The reason why the user should be banned.",
|
||||
delete_messages="Delete messages from the user (choose time period).",
|
||||
)
|
||||
@app_commands.choices(delete_messages=[
|
||||
app_commands.Choice(name="Don't delete any messages", value="none"),
|
||||
app_commands.Choice(name="Last 1 hour", value="1h"),
|
||||
app_commands.Choice(name="Last 6 hours", value="6h"),
|
||||
app_commands.Choice(name="Last 12 hours", value="12h"),
|
||||
app_commands.Choice(name="Last 24 hours", value="1d"),
|
||||
app_commands.Choice(name="Last 3 days", value="3d"),
|
||||
app_commands.Choice(name="Last 7 days", value="7d"),
|
||||
])
|
||||
@app_commands.choices(
|
||||
delete_messages=[
|
||||
app_commands.Choice(name="Don't delete any messages", value="none"),
|
||||
app_commands.Choice(name="Last 1 hour", value="1h"),
|
||||
app_commands.Choice(name="Last 6 hours", value="6h"),
|
||||
app_commands.Choice(name="Last 12 hours", value="12h"),
|
||||
app_commands.Choice(name="Last 24 hours", value="1d"),
|
||||
app_commands.Choice(name="Last 3 days", value="3d"),
|
||||
app_commands.Choice(name="Last 7 days", value="7d"),
|
||||
]
|
||||
)
|
||||
async def ban(
|
||||
self, context, user: discord.User, *, reason: str = "Not specified", delete_messages: str = "none"
|
||||
self,
|
||||
context,
|
||||
user: discord.User,
|
||||
*,
|
||||
reason: str = "Not specified",
|
||||
delete_messages: str = "none",
|
||||
):
|
||||
try:
|
||||
member = context.guild.get_member(user.id)
|
||||
@@ -38,7 +45,10 @@ def ban_command():
|
||||
title="Ban",
|
||||
description=f"**{user}** was banned by **{context.author}**!",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
embed.add_field(name="Reason:", value=reason)
|
||||
await context.send(embed=embed)
|
||||
return
|
||||
@@ -47,7 +57,10 @@ def ban_command():
|
||||
title="Error!",
|
||||
description="I don't have permission to ban this user.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
except Exception:
|
||||
@@ -55,41 +68,56 @@ def ban_command():
|
||||
title="Error!",
|
||||
description="An error occurred while trying to ban the user.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
if not context.author.guild_permissions.ban_members and context.author != context.guild.owner:
|
||||
|
||||
if (
|
||||
not context.author.guild_permissions.ban_members
|
||||
and context.author != context.guild.owner
|
||||
):
|
||||
embed = discord.Embed(
|
||||
title="Missing Permissions!",
|
||||
description="You don't have the `Ban Members` permission to use this command.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
|
||||
if member and member.top_role >= context.guild.me.top_role:
|
||||
embed = discord.Embed(
|
||||
title="Cannot Ban User",
|
||||
description="This user has a higher or equal role to me. Make sure my role is above theirs.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
|
||||
if member and context.author != context.guild.owner:
|
||||
if member.top_role >= context.author.top_role:
|
||||
embed = discord.Embed(
|
||||
title="Cannot Ban User",
|
||||
title="Cannot Ban User",
|
||||
description="You cannot ban this user as they have a higher or equal role to you.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
|
||||
delete_message_days = 0
|
||||
delete_all_messages = False
|
||||
|
||||
|
||||
if delete_messages != "none":
|
||||
if delete_messages == "all":
|
||||
delete_all_messages = True
|
||||
@@ -100,7 +128,7 @@ def ban_command():
|
||||
elif delete_messages.endswith("d"):
|
||||
days = int(delete_messages[:-1])
|
||||
delete_message_days = min(days, 7)
|
||||
|
||||
|
||||
try:
|
||||
if member:
|
||||
try:
|
||||
@@ -108,41 +136,60 @@ def ban_command():
|
||||
title="Ban",
|
||||
description=f"You were banned by **{context.author}** from **{context.guild.name}**!\nReason: {reason}",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await member.send(embed=dm_embed)
|
||||
except (discord.Forbidden, discord.HTTPException):
|
||||
pass
|
||||
|
||||
|
||||
if member:
|
||||
await member.ban(reason=reason, delete_message_days=delete_message_days)
|
||||
await member.ban(
|
||||
reason=reason, delete_message_days=delete_message_days
|
||||
)
|
||||
else:
|
||||
await context.guild.ban(user, reason=reason, delete_message_days=delete_message_days)
|
||||
|
||||
await context.guild.ban(
|
||||
user, reason=reason, delete_message_days=delete_message_days
|
||||
)
|
||||
|
||||
if delete_all_messages:
|
||||
await self.delete_all_user_messages(context.guild, user.id)
|
||||
|
||||
|
||||
embed = discord.Embed(
|
||||
title="Ban",
|
||||
description=f"**{user}** was banned by **{context.author}**!",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
embed.add_field(name="Reason:", value=reason)
|
||||
|
||||
|
||||
if delete_messages != "none":
|
||||
if delete_all_messages:
|
||||
embed.add_field(name="Messages Deleted:", value="All messages", inline=False)
|
||||
embed.add_field(
|
||||
name="Messages Deleted:", value="All messages", inline=False
|
||||
)
|
||||
else:
|
||||
delete_time_text = self.format_delete_time(delete_messages)
|
||||
embed.add_field(name="Messages Deleted:", value=delete_time_text, inline=False)
|
||||
|
||||
embed.add_field(
|
||||
name="Messages Deleted:",
|
||||
value=delete_time_text,
|
||||
inline=False,
|
||||
)
|
||||
|
||||
await context.send(embed=embed)
|
||||
|
||||
|
||||
except discord.Forbidden:
|
||||
embed = discord.Embed(
|
||||
title="Error!",
|
||||
description="I don't have permission to ban this user. Make sure my role is above theirs.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
except discord.HTTPException as e:
|
||||
if "Cannot ban the owner of a guild" in str(e):
|
||||
@@ -150,37 +197,52 @@ def ban_command():
|
||||
title="Cannot Ban User",
|
||||
description="You cannot ban the server owner.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
title="Error!",
|
||||
description=f"Discord API error: {str(e)}",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
except Exception as e:
|
||||
embed = discord.Embed(
|
||||
title="Debug Error!",
|
||||
description=f"Error type: {type(e).__name__}\nError message: {str(e)}",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
embed = discord.Embed(
|
||||
title="Error!",
|
||||
description="An unexpected error occurred.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
async def delete_all_user_messages(self, guild: discord.Guild, user_id: int) -> None:
|
||||
async def delete_all_user_messages(
|
||||
self, guild: discord.Guild, user_id: int
|
||||
) -> None:
|
||||
for channel in guild.text_channels:
|
||||
try:
|
||||
permissions = channel.permissions_for(guild.me)
|
||||
if not (permissions.read_message_history and permissions.manage_messages):
|
||||
if not (
|
||||
permissions.read_message_history and permissions.manage_messages
|
||||
):
|
||||
continue
|
||||
|
||||
|
||||
deleted = True
|
||||
while deleted:
|
||||
deleted = False
|
||||
@@ -190,23 +252,27 @@ def ban_command():
|
||||
try:
|
||||
await message.delete()
|
||||
deleted = True
|
||||
except (discord.NotFound, discord.Forbidden, discord.HTTPException):
|
||||
except (
|
||||
discord.NotFound,
|
||||
discord.Forbidden,
|
||||
discord.HTTPException,
|
||||
):
|
||||
continue
|
||||
except (discord.Forbidden, discord.HTTPException):
|
||||
break
|
||||
|
||||
|
||||
except (discord.Forbidden, discord.HTTPException):
|
||||
continue
|
||||
|
||||
def format_delete_time(self, delete_option: str) -> str:
|
||||
time_formats = {
|
||||
"1h": "Last 1 hour",
|
||||
"6h": "Last 6 hours",
|
||||
"6h": "Last 6 hours",
|
||||
"12h": "Last 12 hours",
|
||||
"1d": "Last 24 hours",
|
||||
"3d": "Last 3 days",
|
||||
"7d": "Last 7 days"
|
||||
"7d": "Last 7 days",
|
||||
}
|
||||
return time_formats.get(delete_option, "Unknown time period")
|
||||
|
||||
return ban
|
||||
|
||||
return ban
|
||||
|
||||
@@ -15,9 +15,7 @@ def hackban_command():
|
||||
user_id="The user ID that should be banned.",
|
||||
reason="The reason why the user should be banned.",
|
||||
)
|
||||
async def hackban(
|
||||
self, context, user_id: str, *, reason: str = "Not specified"
|
||||
):
|
||||
async def hackban(self, context, user_id: str, *, reason: str = "Not specified"):
|
||||
"""
|
||||
Bans a user without the user having to be in the server.
|
||||
|
||||
@@ -34,7 +32,9 @@ def hackban_command():
|
||||
title="Ban",
|
||||
description=f"**{user}** (ID: {user_id}) was banned by **{context.author}**!",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
embed.add_field(name="Reason:", value=reason)
|
||||
await context.send(embed=embed)
|
||||
except Exception:
|
||||
@@ -42,7 +42,9 @@ def hackban_command():
|
||||
title="Error!",
|
||||
description="An error occurred while trying to ban the user. Make sure ID is an existing ID that belongs to a user.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
|
||||
|
||||
return hackban
|
||||
|
||||
@@ -13,9 +13,7 @@ def kick_command():
|
||||
user="The user that should be kicked.",
|
||||
reason="The reason why the user should be kicked.",
|
||||
)
|
||||
async def kick(
|
||||
self, context, user: discord.User, *, reason: str = "Not specified"
|
||||
):
|
||||
async def kick(self, context, user: discord.User, *, reason: str = "Not specified"):
|
||||
try:
|
||||
member = context.guild.get_member(user.id)
|
||||
if not member:
|
||||
@@ -26,38 +24,53 @@ def kick_command():
|
||||
title="Error!",
|
||||
description="This user is not in the server.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
if not context.author.guild_permissions.kick_members and context.author != context.guild.owner:
|
||||
|
||||
if (
|
||||
not context.author.guild_permissions.kick_members
|
||||
and context.author != context.guild.owner
|
||||
):
|
||||
embed = discord.Embed(
|
||||
title="Missing Permissions!",
|
||||
description="You don't have the `Kick Members` permission to use this command.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
|
||||
if member and member.top_role >= context.guild.me.top_role:
|
||||
embed = discord.Embed(
|
||||
title="Cannot Kick User",
|
||||
description="This user has a higher or equal role to me. Make sure my role is above theirs.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
|
||||
if member and context.author != context.guild.owner:
|
||||
if member.top_role >= context.author.top_role:
|
||||
embed = discord.Embed(
|
||||
title="Cannot Kick User",
|
||||
title="Cannot Kick User",
|
||||
description="You cannot kick this user as they have a higher or equal role to you.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
|
||||
try:
|
||||
if member:
|
||||
try:
|
||||
@@ -66,29 +79,37 @@ def kick_command():
|
||||
title="Kick",
|
||||
description=f"You were kicked by **{context.author}** from **{context.guild.name}**!\nReason: {reason}",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
)
|
||||
except (discord.Forbidden, discord.HTTPException):
|
||||
pass
|
||||
|
||||
|
||||
await member.kick(reason=reason)
|
||||
|
||||
|
||||
embed = discord.Embed(
|
||||
title="Kick",
|
||||
description=f"**{user}** was kicked by **{context.author}**!",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
embed.add_field(name="Reason:", value=reason)
|
||||
|
||||
|
||||
await context.send(embed=embed)
|
||||
|
||||
|
||||
except discord.Forbidden:
|
||||
embed = discord.Embed(
|
||||
title="Error!",
|
||||
description="I don't have permission to kick this user. Make sure my role is above theirs.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
except discord.HTTPException as e:
|
||||
if "Cannot kick the owner of a guild" in str(e):
|
||||
@@ -96,28 +117,39 @@ def kick_command():
|
||||
title="Cannot Kick User",
|
||||
description="You cannot kick the server owner.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
title="Error!",
|
||||
description=f"Discord API error: {str(e)}",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
except Exception as e:
|
||||
embed = discord.Embed(
|
||||
title="Debug Error!",
|
||||
description=f"Error type: {type(e).__name__}\nError message: {str(e)}",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
embed = discord.Embed(
|
||||
title="Error!",
|
||||
description="An unexpected error occurred.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
|
||||
return kick
|
||||
|
||||
@@ -13,9 +13,7 @@ def nick_command():
|
||||
user="The user that should have a new nickname.",
|
||||
nickname="The new nickname that should be set.",
|
||||
)
|
||||
async def nick(
|
||||
self, context, user: discord.User, *, nickname: str = None
|
||||
):
|
||||
async def nick(self, context, user: discord.User, *, nickname: str = None):
|
||||
"""
|
||||
Change the nickname of a user on a server.
|
||||
|
||||
@@ -28,15 +26,19 @@ def nick_command():
|
||||
title="Missing Permissions!",
|
||||
description="You are missing the permission(s) `manage_nicknames` to execute this command!",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
return await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
|
||||
if not context.guild.me.guild_permissions.manage_nicknames:
|
||||
embed = discord.Embed(
|
||||
title="Missing Permissions!",
|
||||
description="I am missing the permission(s) `manage_nicknames` to execute this command!",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
return await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
member = context.guild.get_member(user.id) or await context.guild.fetch_member(
|
||||
@@ -48,14 +50,18 @@ def nick_command():
|
||||
title="Nickname",
|
||||
description=f"**{member}'s** new nickname is **{nickname}**!",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
except:
|
||||
embed = discord.Embed(
|
||||
title="Missing Permissions!",
|
||||
description="An error occurred while trying to change the nickname of the user. Make sure my role is above the role of the user you want to change the nickname.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
|
||||
return nick
|
||||
|
||||
@@ -3,6 +3,7 @@ from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
|
||||
def purge_command():
|
||||
@commands.hybrid_command(
|
||||
name="purge",
|
||||
@@ -12,36 +13,39 @@ def purge_command():
|
||||
@commands.bot_has_permissions(manage_messages=True)
|
||||
@app_commands.describe(
|
||||
amount="The amount of messages that should be deleted.",
|
||||
user="The user whose messages should be deleted (optional)."
|
||||
user="The user whose messages should be deleted (optional).",
|
||||
)
|
||||
async def purge(self, context, amount: int, user: discord.Member = None):
|
||||
if context.interaction:
|
||||
await context.defer(ephemeral=True)
|
||||
|
||||
|
||||
if user:
|
||||
deleted_count = 0
|
||||
|
||||
|
||||
def check(message):
|
||||
nonlocal deleted_count
|
||||
if message.author == user and deleted_count < amount:
|
||||
deleted_count += 1
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
purged_messages = await context.channel.purge(limit=300, check=check)
|
||||
else:
|
||||
purged_messages = await context.channel.purge(limit=amount)
|
||||
|
||||
|
||||
embed = discord.Embed(
|
||||
title="Purge",
|
||||
description=f"**{context.author}** cleared **{len(purged_messages)}** messages!" + (f" from **{user}**" if user else ""),
|
||||
description=f"**{context.author}** cleared **{len(purged_messages)}** messages!"
|
||||
+ (f" from **{user}**" if user else ""),
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
|
||||
embed.set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
|
||||
if context.interaction:
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
else:
|
||||
await context.send(embed=embed, delete_after=10)
|
||||
|
||||
return purge
|
||||
|
||||
return purge
|
||||
|
||||
@@ -13,6 +13,7 @@ def timeout_command():
|
||||
app_commands.Choice(name="1 day", value="1d"),
|
||||
app_commands.Choice(name="1 week", value="1w"),
|
||||
]
|
||||
|
||||
@commands.hybrid_command(
|
||||
name="timeout",
|
||||
description="Timeout a user for a specified duration.",
|
||||
@@ -24,7 +25,12 @@ def timeout_command():
|
||||
)
|
||||
@app_commands.choices(duration=DURATION_CHOICES)
|
||||
async def timeout(
|
||||
self, context, user: discord.User, duration: str, *, reason: str = "Not specified"
|
||||
self,
|
||||
context,
|
||||
user: discord.User,
|
||||
duration: str,
|
||||
*,
|
||||
reason: str = "Not specified",
|
||||
):
|
||||
try:
|
||||
member = context.guild.get_member(user.id)
|
||||
@@ -36,16 +42,25 @@ def timeout_command():
|
||||
title="Error!",
|
||||
description="This user is not in the server.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
if not context.author.guild_permissions.moderate_members and context.author != context.guild.owner:
|
||||
if (
|
||||
not context.author.guild_permissions.moderate_members
|
||||
and context.author != context.guild.owner
|
||||
):
|
||||
embed = discord.Embed(
|
||||
title="Missing Permissions!",
|
||||
description="You don't have the `Timeout Members` permission to use this command.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
@@ -54,7 +69,10 @@ def timeout_command():
|
||||
title="Cannot Timeout User",
|
||||
description="This user has a higher or equal role to me. Make sure my role is above theirs.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
@@ -64,7 +82,10 @@ def timeout_command():
|
||||
title="Cannot Timeout User",
|
||||
description="You cannot timeout this user as they have a higher or equal role to you.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
@@ -74,7 +95,10 @@ def timeout_command():
|
||||
title="Invalid Duration",
|
||||
description="Choose one of: 60 secs, 5 mins, 10 mins, 1 hour, 1 day, 1 week.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
@@ -89,9 +113,14 @@ def timeout_command():
|
||||
title="Timeout",
|
||||
description=f"**{user}** was timed out by **{context.author}**!",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
embed.add_field(name="Reason:", value=reason)
|
||||
embed.add_field(name="Duration:", value=_format_duration(duration), inline=False)
|
||||
embed.add_field(
|
||||
name="Duration:", value=_format_duration(duration), inline=False
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
|
||||
except discord.Forbidden:
|
||||
@@ -99,21 +128,30 @@ def timeout_command():
|
||||
title="Error!",
|
||||
description="I don't have permission to timeout this user. Make sure my role is above theirs.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
except discord.HTTPException as e:
|
||||
embed = discord.Embed(
|
||||
title="Error!",
|
||||
description=f"Discord API error: {str(e)}",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
except Exception as e:
|
||||
embed = discord.Embed(
|
||||
title="Debug Error!",
|
||||
description=f"Error type: {type(e).__name__}\nError message: {str(e)}",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation",
|
||||
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
except Exception:
|
||||
@@ -121,13 +159,19 @@ def timeout_command():
|
||||
title="Error!",
|
||||
description="An unexpected error occurred.",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
|
||||
@timeout.autocomplete("duration")
|
||||
async def duration_autocomplete(interaction: discord.Interaction, current: str):
|
||||
query = (current or "").lower()
|
||||
filtered = [c for c in DURATION_CHOICES if query in c.name.lower() or query in c.value.lower()]
|
||||
filtered = [
|
||||
c
|
||||
for c in DURATION_CHOICES
|
||||
if query in c.name.lower() or query in c.value.lower()
|
||||
]
|
||||
return filtered[:25]
|
||||
|
||||
return timeout
|
||||
@@ -172,5 +216,3 @@ def _format_duration(duration: str) -> str:
|
||||
return f"{value} seconds"
|
||||
except Exception:
|
||||
return duration
|
||||
|
||||
|
||||
|
||||
@@ -5,13 +5,17 @@ from discord.ext.commands import Context
|
||||
|
||||
|
||||
def warnings_command():
|
||||
async def send_embed(context, embed: discord.Embed, *, ephemeral: bool = False) -> None:
|
||||
async def send_embed(
|
||||
context, embed: discord.Embed, *, ephemeral: bool = False
|
||||
) -> None:
|
||||
interaction = getattr(context, "interaction", None)
|
||||
if interaction is not None:
|
||||
if interaction.response.is_done():
|
||||
await interaction.followup.send(embed=embed, ephemeral=ephemeral)
|
||||
else:
|
||||
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
|
||||
await interaction.response.send_message(
|
||||
embed=embed, ephemeral=ephemeral
|
||||
)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
@@ -30,16 +34,20 @@ def warnings_command():
|
||||
title="Missing Permissions!",
|
||||
description="You are missing the permission(s) `manage_messages` to execute this command!",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
return await self.send_embed(context, embed, ephemeral=True)
|
||||
|
||||
|
||||
if context.invoked_subcommand is None:
|
||||
embed = discord.Embed(
|
||||
title="Warning",
|
||||
description="Please specify a subcommand.\n\n**Subcommands:**\n`add` - Add a warning to a user.\n`remove` - Remove a warning from a user.\n`list` - List all warnings of a user.",
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
embed.set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await self.send_embed(context, embed)
|
||||
|
||||
@warning.command(
|
||||
@@ -65,7 +73,9 @@ def warnings_command():
|
||||
title="Missing Permissions!",
|
||||
description="You are missing the permission(s) `manage_messages` to execute this command!",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
return await self.send_embed(context, embed, ephemeral=True)
|
||||
member = context.guild.get_member(user.id) or await context.guild.fetch_member(
|
||||
user.id
|
||||
@@ -78,7 +88,9 @@ def warnings_command():
|
||||
description=f"**{member}** was warned by **{context.author}**!\nTotal warns for this user: {total}",
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
embed.set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
embed.add_field(name="Reason:", value=reason)
|
||||
await self.send_embed(context, embed)
|
||||
try:
|
||||
@@ -87,7 +99,9 @@ def warnings_command():
|
||||
description=f"You were warned by **{context.author}** in **{context.guild.name}**!\nReason: {reason}",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
dm_embed.set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
dm_embed.set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await member.send(embed=dm_embed)
|
||||
except:
|
||||
fallback = discord.Embed(
|
||||
@@ -120,7 +134,9 @@ def warnings_command():
|
||||
title="Missing Permissions!",
|
||||
description="You are missing the permission(s) `manage_messages` to execute this command!",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
return await self.send_embed(context, embed, ephemeral=True)
|
||||
member = context.guild.get_member(user.id) or await context.guild.fetch_member(
|
||||
user.id
|
||||
@@ -131,7 +147,9 @@ def warnings_command():
|
||||
description=f"Removed the warning **#{warn_id}** from **{member}**!\nTotal warns for this user: {total}",
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
embed.set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
await self.send_embed(context, embed)
|
||||
|
||||
@warning.command(
|
||||
@@ -151,11 +169,15 @@ def warnings_command():
|
||||
title="Missing Permissions!",
|
||||
description="You are missing the permission(s) `manage_messages` to execute this command!",
|
||||
color=0xE02B2B,
|
||||
).set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
).set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
return await self.send_embed(context, embed, ephemeral=True)
|
||||
warnings_list = await self.bot.database.get_warnings(user.id, context.guild.id)
|
||||
embed = discord.Embed(title=f"Warnings of {user}", color=0x7289DA)
|
||||
embed.set_author(name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png")
|
||||
embed.set_author(
|
||||
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
|
||||
)
|
||||
description = ""
|
||||
if len(warnings_list) == 0:
|
||||
description = "This user has no warnings."
|
||||
@@ -165,6 +187,4 @@ def warnings_command():
|
||||
embed.description = description
|
||||
await self.send_embed(context, embed)
|
||||
|
||||
|
||||
|
||||
return warning
|
||||
|
||||
Reference in New Issue
Block a user