From 29bd3babea96c62d1e26fcf3335ed21b8106f76b Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Mon, 8 Jun 2026 23:23:37 -0700 Subject: [PATCH] This combines nickname and nicknamefix into one file --- modules/moderation/nickname.py | 38 ++++++++++++++++++- modules/moderation/nicknamefix.py | 63 ------------------------------- 2 files changed, 37 insertions(+), 64 deletions(-) delete mode 100644 modules/moderation/nicknamefix.py diff --git a/modules/moderation/nickname.py b/modules/moderation/nickname.py index 8ebd5059..68b2e64c 100644 --- a/modules/moderation/nickname.py +++ b/modules/moderation/nickname.py @@ -14,12 +14,13 @@ from typing import TYPE_CHECKING, Self import discord +from discord import app_commands from discord.ext import commands from unidecode import unidecode import configuration from botlogging import LogContext, LogLevel -from core import cogs +from core import auxiliary, cogs if TYPE_CHECKING: import bot @@ -138,6 +139,41 @@ async def response( context=LogContext(guild=ctx.author.guild), ) + @app_commands.checks.has_permissions(manage_nicknames=True) + @app_commands.command( + name="nicknamefix", + description="Auto adjusts a nickname of the given member", + ) + async def fixnickname( + self: Self, interaction: discord.Interaction, member: discord.Member + ) -> None: + """Manually adjusts someones nickname to comply with the nickname filter + Does not send a DM + + Args: + interaction (discord.Interaction): The interaction the command was called at + member (discord.Member): The member to update the nickname for + """ + if member.bot: + embed = auxiliary.prepare_deny_embed("Bots don't get new nicknames") + return + new_nickname = format_username(member.display_name) + if new_nickname == member.display_name: + embed = auxiliary.prepare_deny_embed( + f"{member.mention} doesn't need a new nickname" + ) + await interaction.response.send_message(embed=embed) + return + await member.edit( + nick=new_nickname, + reason=f"Change nickname command, ran by {interaction.user}", + ) + embed = auxiliary.prepare_confirm_embed( + f"{member.mention} name changed to {new_nickname}" + ) + await interaction.response.send_message(embed=embed) + return + @commands.Cog.listener() async def on_member_join(self: Self, member: discord.Member) -> None: """ diff --git a/modules/moderation/nicknamefix.py b/modules/moderation/nicknamefix.py deleted file mode 100644 index 6dde0b0b..00000000 --- a/modules/moderation/nicknamefix.py +++ /dev/null @@ -1,63 +0,0 @@ -"""This holds a command to manually adjust someones nickname -Uses the same filter as the automatic nickname filter""" - -from __future__ import annotations - -from typing import TYPE_CHECKING, Self - -import discord -from discord import app_commands - -from core import auxiliary, cogs -from modules.moderation import nickname - -if TYPE_CHECKING: - import bot - - -async def setup(bot: bot.TechSupportBot) -> None: - """Registers the nicknamefixer cog - - Args: - bot (bot.TechSupportBot): The bot to register the cog to - """ - await bot.add_cog(NicknameFixer(bot=bot)) - - -class NicknameFixer(cogs.BaseCog): - """The class that holds the nickname fixer""" - - @app_commands.checks.has_permissions(manage_nicknames=True) - @app_commands.command( - name="nicknamefix", - description="Auto adjusts a nickname of the given member", - ) - async def fixnickname( - self: Self, interaction: discord.Interaction, member: discord.Member - ) -> None: - """Manually adjusts someones nickname to comply with the nickname filter - Does not send a DM - - Args: - interaction (discord.Interaction): The interaction the command was called at - member (discord.Member): The member to update the nickname for - """ - if member.bot: - embed = auxiliary.prepare_deny_embed("Bots don't get new nicknames") - return - new_nickname = nickname.format_username(member.display_name) - if new_nickname == member.display_name: - embed = auxiliary.prepare_deny_embed( - f"{member.mention} doesn't need a new nickname" - ) - await interaction.response.send_message(embed=embed) - return - await member.edit( - nick=new_nickname, - reason=f"Change nickname command, ran by {interaction.user}", - ) - embed = auxiliary.prepare_confirm_embed( - f"{member.mention} name changed to {new_nickname}" - ) - await interaction.response.send_message(embed=embed) - return