1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:23:12 +00:00

feat: Add /config set_prefix command to change bot prefix

This commit is contained in:
wlinator 2024-08-30 06:47:39 -04:00
parent 6d7b863ece
commit 34ab76e4c5

View file

@ -657,6 +657,41 @@ class Config(commands.GroupCog, group_name="config"):
await interaction.response.send_message(embed=success_embed)
@prefix.command(name="set")
async def set_prefix(self, interaction: discord.Interaction, prefix: str) -> None:
"""
Set the prefix for the bot in the server.
Parameters
----------
interaction : discord.Interaction
The interaction to set the prefix for.
prefix : str
The prefix to set for the bot.
"""
assert interaction.guild
if len(prefix) > 25:
embed = Builder.create_embed(
theme="error",
user_name=interaction.user.name,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_prefix_too_long"],
)
await interaction.response.send_message(embed=embed)
return
guild_config = GuildConfig(interaction.guild.id)
GuildConfig.set_prefix(guild_config.guild_id, prefix)
embed = Builder.create_embed(
theme="success",
user_name=interaction.user.name,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_prefix_set"].format(prefix),
)
await interaction.response.send_message(embed=embed)
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Config(bot))