I want to use guild slash command. but cannot register.
i can use role command but cannot use set_role
I use ext.Cog. version: 2.0.0rc1
from typing import List
from discord import ApplicationContext, Option, Role
from discord.ext.commands import Cog, Bot, slash_command, command, Context
class RoleManager(Cog):
def __init__(self, bot: Bot):
self.bot = bot
@slash_command(guild_ids=[893402769254404117])
async def set_role(
self,
ctx: ApplicationContext,
role_id: Option(int, description="Choice Role")
):
role = ctx.guild.get_role(int(role_id))
if await ctx.author.add_roles(role):
await ctx.respond(f"{role.mention} added.", ephemeral=True)
@command()
async def role(
self,
ctx: Context,
role_id: str
):
if not role_id: return await ctx.send("required role id.")
if not role_id.isdigit(): return await ctx.send("you type integer number of role.")
await ctx.author.add_roles(ctx.guild.get_role(int(role_id)))
def setup(bot: Bot):
bot.add_cog(RoleManager(bot=bot))