简体   繁体   English

如何使用 discord.py 将按钮嵌入到我的消息中?

[英]How can I embed buttons to my message using discord.py?

I am making a discord bot using discord.py (with slash commands), but I am stuck on embedding buttons to my message.我正在使用 discord.py(使用斜杠命令)制作一个 discord 机器人,但我一直坚持将按钮嵌入到我的消息中。 I can send the messages fine but once I try to put embeds there is always an error.我可以很好地发送消息,但是一旦我尝试嵌入,总是会出现错误。

I've tried using: from discord_components import Button我试过使用: from discord_components import Button

But here's the error message:但这是错误消息:

from discord_components import Button

ModuleNotFoundError: No module named 'discord_components'

I've looked into many SO questions but most of the answers don't work (ModuleNotFoundError) or do not support slash commands我研究了很多 SO 问题,但大多数答案都不起作用(ModuleNotFoundError)或不支持斜杠命令

Note: if it helps, I'm using replit as my IDE.注意:如果有帮助,我正在使用 replit 作为我的 IDE。

Your import might be wrong, try this.您的导入可能是错误的,试试这个。

from discord.ui import Button, View

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM