2024-03-30 22:02:36 +00:00
|
|
|
import discord
|
|
|
|
from discord import app_commands
|
|
|
|
from discord.ext import commands
|
|
|
|
|
|
|
|
|
|
|
|
class Roles(commands.Cog):
|
|
|
|
def __init__(self, bot: commands.Bot) -> None:
|
|
|
|
self.bot = bot
|
|
|
|
|
refactor(git.py): rename 'git' instance to 'github' for better clarity
style(git.py): shorten long lines to improve readability
feat(xkcd.py): add XkcdLinkButtons class to provide link buttons for xkcd comics
style(neofetch.py, xkcd.py): shorten long lines to improve readability
refactor(xkcd.py): move XkcdLinkButtons class to the top for better organization
refactor(roles.py): rename group to role for better semantics
style(roles.py, run.py, temp_vc.py, tty_roles.py, purge.py, avatar.py, guide.py, info.py, membercount.py): simplify function calls and conditions for better readability
fix(report.py): simplify report submission process, remove webhook creation and deletion
feat(avatar.py): add prefix command for getting member avatar
chore(roles.py, run.py, temp_vc.py, purge.py, avatar.py, membercount.py): remove logger calls to reduce verbosity
style: refactor multiline function calls and conditions to single line for better readability
fix(snippets.py): correct database controller attribute from 'snippets' to 'snippet' to match the correct database table name
2024-07-02 02:32:28 +00:00
|
|
|
role = app_commands.Group(name="roles", description="Role commands.")
|
2024-03-30 22:02:36 +00:00
|
|
|
|
2024-03-31 18:20:29 +00:00
|
|
|
@app_commands.checks.has_any_role("Admin")
|
refactor(git.py): rename 'git' instance to 'github' for better clarity
style(git.py): shorten long lines to improve readability
feat(xkcd.py): add XkcdLinkButtons class to provide link buttons for xkcd comics
style(neofetch.py, xkcd.py): shorten long lines to improve readability
refactor(xkcd.py): move XkcdLinkButtons class to the top for better organization
refactor(roles.py): rename group to role for better semantics
style(roles.py, run.py, temp_vc.py, tty_roles.py, purge.py, avatar.py, guide.py, info.py, membercount.py): simplify function calls and conditions for better readability
fix(report.py): simplify report submission process, remove webhook creation and deletion
feat(avatar.py): add prefix command for getting member avatar
chore(roles.py, run.py, temp_vc.py, purge.py, avatar.py, membercount.py): remove logger calls to reduce verbosity
style: refactor multiline function calls and conditions to single line for better readability
fix(snippets.py): correct database controller attribute from 'snippets' to 'snippet' to match the correct database table name
2024-07-02 02:32:28 +00:00
|
|
|
@role.command(name="create", description="Creates a role in the guild.")
|
2024-03-30 21:53:12 +00:00
|
|
|
async def create(self, interaction: discord.Interaction, name: str) -> None:
|
2024-05-01 06:19:14 +00:00
|
|
|
"""
|
|
|
|
Creates a role in the guild.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
interaction : discord.Interaction
|
|
|
|
The interaction object.
|
|
|
|
name : str
|
|
|
|
The name of the role to create.
|
|
|
|
"""
|
|
|
|
|
2024-03-30 21:53:12 +00:00
|
|
|
if interaction.guild is not None:
|
|
|
|
role = await interaction.guild.create_role(name=name)
|
2024-05-01 06:19:14 +00:00
|
|
|
|
2024-03-30 21:53:12 +00:00
|
|
|
await interaction.response.send_message(f"Created role {role.name}.")
|
|
|
|
|
2024-03-31 18:20:29 +00:00
|
|
|
@app_commands.checks.has_any_role("Admin")
|
refactor(git.py): rename 'git' instance to 'github' for better clarity
style(git.py): shorten long lines to improve readability
feat(xkcd.py): add XkcdLinkButtons class to provide link buttons for xkcd comics
style(neofetch.py, xkcd.py): shorten long lines to improve readability
refactor(xkcd.py): move XkcdLinkButtons class to the top for better organization
refactor(roles.py): rename group to role for better semantics
style(roles.py, run.py, temp_vc.py, tty_roles.py, purge.py, avatar.py, guide.py, info.py, membercount.py): simplify function calls and conditions for better readability
fix(report.py): simplify report submission process, remove webhook creation and deletion
feat(avatar.py): add prefix command for getting member avatar
chore(roles.py, run.py, temp_vc.py, purge.py, avatar.py, membercount.py): remove logger calls to reduce verbosity
style: refactor multiline function calls and conditions to single line for better readability
fix(snippets.py): correct database controller attribute from 'snippets' to 'snippet' to match the correct database table name
2024-07-02 02:32:28 +00:00
|
|
|
@role.command(name="delete", description="Deletes a role in the guild.")
|
2024-03-30 22:02:36 +00:00
|
|
|
async def delete(self, interaction: discord.Interaction, role: discord.Role) -> None:
|
2024-05-01 06:19:14 +00:00
|
|
|
"""
|
|
|
|
Deletes a role in the guild.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
interaction : discord.Interaction
|
|
|
|
The interaction object.
|
|
|
|
role : discord.Role
|
|
|
|
The role to delete.
|
|
|
|
"""
|
|
|
|
|
2024-03-30 22:02:36 +00:00
|
|
|
await role.delete()
|
2024-05-01 06:19:14 +00:00
|
|
|
|
2024-03-30 22:02:36 +00:00
|
|
|
await interaction.response.send_message(f"Deleted role {role.name}.")
|
2024-03-31 17:58:05 +00:00
|
|
|
|
2024-03-30 22:02:36 +00:00
|
|
|
|
|
|
|
async def setup(bot: commands.Bot) -> None:
|
|
|
|
await bot.add_cog(Roles(bot))
|