第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

子命令問題:ctx.invoked_subcommands 始終為 None

子命令問題:ctx.invoked_subcommands 始終為 None

慕的地6264312 2021-06-29 02:33:44
編輯:已找到解決方案嘗試將子命令的名稱更改為_enabled和_disabled并傳遞name="enabled" name="disabled"給命令裝飾器。這是一個(gè)猜測,但有時(shí) Bot 內(nèi)部使用的名稱在用作命令名稱時(shí)無法正常工作。- 帕特里克·豪我嘗試清理一些代碼并嘗試將子命令實(shí)現(xiàn)到模塊中,但我遇到了一個(gè)似乎無法解決的問題。首先,這里是代碼:@commands.group()@commands.has_permissions(administrator=True)async def autorole(self, ctx):    exists = dbinteraction.dbexec("SELECT role from autorole WHERE server_id = {}".format(ctx.guild.id))    if ctx.invoked_subcommand is None:        em = None        if (exists == None):            em = discord.Embed(title="Autorole is disabled for this guild.", color=discord.Color(0xff0000))        else:            em = discord.Embed(title="Autorole is enabled for this guild.", color = discord.Color(0x32ff00))            rol = discord.utils.get(ctx.guild.roles, id=exists)            em.add_field(name="Current role:", value=rol.mention)        await ctx.send(embed=em)@autorole.command()@commands.has_permissions(administrator=True)async def enabled(self, ctx, role: discord.Role=None):    """Defines a role that will be applied to all new members, format: autorole (enabled/disabled) [role]"""    exists = dbinteraction.dbexec("SELECT role from autorole WHERE server_id = {}".format(ctx.guild.id))    print('status, role : {} {}'.format("enabled", role.id))    try:        if role==None:            await ctx.send("No role provided")        else:            if (exists!=None):                dbinteraction.dbexec("UPDATE autorole SET role = {}".format(role.id))            else:                dbinteraction.dbexec("INSERT INTO autorole VALUES({},{})".format(ctx.guild.id, role.id))                em = discord.Embed(title="", color= discord.Color(0x32ff00))                em.add_field(name="Autorole enabled", value="Current role: {}".format(role.mention))                await ctx.send(embed=em)    except (Exception) as e:        print(e)無論我嘗試什么,以下代碼始終執(zhí)行默認(rèn)命令(之后的if ctx.invoked_subcommand is None:),我正在使用重寫
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 275 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)