英文:
AttributeError: module 'discord' has no attribute 'interaction'
问题
discord.py没有"interaction"属性,这是我新的Discord机器人需要的。
这是我的代码:
@bot.tree.command(name="help")
async def help(interaction: discord.interaction):
await interaction.response.send_message("Hey, das ist ein Test")
我尝试过,但出现了"AttributeError: module 'discord' has no attribute 'interaction'"的错误。
英文:
discord.py has not the attribute "interaction", which i need for my new discord bot.
This is my code:
@bot.tree.command(name="help")
async def help(interaction: discord.interaction):
await interaction.response.send_message(f"Hey, das ist ein test")
I tried "AttributeError: module 'discord' has no attribute 'interaction'"
答案1
得分: 4
那应该是 discord.Interaction
,而不是 discord.interaction
。确保使用大写的 I
。这里 是相关的 API 文档链接。
英文:
That would be discord.Interaction
, not discord.interaction
. Make sure you are using a capital I
. Here is the link to the relevant API docs.
答案2
得分: 0
After reviewing your code, it looks like you're missing a capital I
in discord.Interaction
. However, if it still doesn't work after modifications made, consider looking at the version of discord.py you are using. Maybe it is not the 2.0.0 (minimum)
.
And if it is the right version, try using this way of making it:
#imports
intents = discord.Intents.all() # defining intents
intents.members = True
bot = discord.AutoShardedClient(intents = intents, shard_count = 1) # Making a new bot
slash = app_commands.CommandTree(bot) # Declaring commandTree
@slash.command(name="help")
async def help(interaction: discord.Interaction):
await interaction.response.send_message("Hey, das ist ein test")
英文:
After reviewing your code, it looks like you're missing a capital I
in discord.Interaction
.
However, if it still doesn't work after modifications made, consider looking at the version of discord.py you are using. Maybe it is not the 2.0.0 (minimum)
And if it is the right version, try using this way of making it:
#imports
intents = discord.Intents.all() # defining intents
intents.members = True
bot = discord.AutoShardedClient(intents = intents, shard_count = 1) # Making a new bot
slash = app_commands.CommandTree(bot) # Declaring commandTree
@slash.command(name = "help")
async def help(interaction: discord.Interaction):
await interaction.response.send_message(f"Hey, das ist ein test")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论