'HelpSelect' 没有 'commands' 的属性
'HelpSelect' has no attribute to 'commands'
我收到以下错误:每当有人在下拉列表中选择一个选项时,'HelpSelect' 没有 'commands' 的属性。
这是我的代码:
class HelpSelect(nextcord.ui.Select):
def __init__(self):
options = [
nextcord.SelectOption(label= 'Fun', description= 'Fun commands', emoji= '<:blanket:915928436223143956>'),
nextcord.SelectOption(label= 'Economy', description= 'Economy commands', emoji= ''),
nextcord.SelectOption(label= 'Utility', description= 'Utility commands', emoji= '⚙'),
nextcord.SelectOption(label= 'PikaNetwork', description= 'Pika commands', emoji= '<:PikaYay:831858710162047007>'),
nextcord.SelectOption(label= 'Moderation', description= 'Moderation commands', emoji= '<:developer:940842823165567016>')
]
super().__init__(placeholder= 'Choose something...', min_values= 1, max_values=1, options=options)
async def callback(self, interaction: nextcord.Interaction):
x = []
for command in self.bot.commands:
if command.cog and command.cog.qualified_name == self.values[0]:
x.append(command.name)
e1= nextcord.Embed(
title= f'test',
description= f', '.join(x),
color= nextcord.Colour.blue()
)
await interaction.response.send_message(embed=e1, ephemeral=True)
尝试从 for command in self.bot.commands:
中删除 self
。
如果您使用 client = nextcord.Client()
而不是 bot = commands.Bot(command_prefix="$")
注册您的机器人,请将 bot
更改为 client
。
我收到以下错误:每当有人在下拉列表中选择一个选项时,'HelpSelect' 没有 'commands' 的属性。
这是我的代码:
class HelpSelect(nextcord.ui.Select):
def __init__(self):
options = [
nextcord.SelectOption(label= 'Fun', description= 'Fun commands', emoji= '<:blanket:915928436223143956>'),
nextcord.SelectOption(label= 'Economy', description= 'Economy commands', emoji= ''),
nextcord.SelectOption(label= 'Utility', description= 'Utility commands', emoji= '⚙'),
nextcord.SelectOption(label= 'PikaNetwork', description= 'Pika commands', emoji= '<:PikaYay:831858710162047007>'),
nextcord.SelectOption(label= 'Moderation', description= 'Moderation commands', emoji= '<:developer:940842823165567016>')
]
super().__init__(placeholder= 'Choose something...', min_values= 1, max_values=1, options=options)
async def callback(self, interaction: nextcord.Interaction):
x = []
for command in self.bot.commands:
if command.cog and command.cog.qualified_name == self.values[0]:
x.append(command.name)
e1= nextcord.Embed(
title= f'test',
description= f', '.join(x),
color= nextcord.Colour.blue()
)
await interaction.response.send_message(embed=e1, ephemeral=True)
尝试从
for command in self.bot.commands:
中删除self
。如果您使用
client = nextcord.Client()
而不是bot = commands.Bot(command_prefix="$")
注册您的机器人,请将bot
更改为client
。