1
Fork 0
mirror of https://github.com/allthingslinux/tux.git synced 2024-10-03 09:03:12 +00:00

feat(roles.py): add new roles cog for guild role management

feat(roles.py): add create command to create new roles in the guild
This commit is contained in:
kzndotsh 2024-03-30 21:53:12 +00:00
parent 77069d6078
commit 760b3ff307

22
tux/cogs/guild/roles.py Normal file
View file

@ -0,0 +1,22 @@
import discord
from discord import app_commands
from discord.ext import commands
from loguru import logger
class Roles(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
group = app_commands.Group(name="roles", description="Role commands.")
@group.command(name="create", description="Creates a role in the guild.")
async def create(self, interaction: discord.Interaction, name: str) -> None:
if interaction.guild is not None:
role = await interaction.guild.create_role(name=name)
await interaction.response.send_message(f"Created role {role.name}.")
logger.info(f"{interaction.user} created role {role.name}.")
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Roles(bot))