mirror of
https://github.com/allthingslinux/tux.git
synced 2024-10-03 00:53: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:
parent
77069d6078
commit
760b3ff307
1 changed files with 22 additions and 0 deletions
22
tux/cogs/guild/roles.py
Normal file
22
tux/cogs/guild/roles.py
Normal 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))
|
Loading…
Reference in a new issue