我想看看谁单击了Discord.py上的按钮,我该怎么办?
我正在为我的Discord服务器制作一个机器人,我想看看谁单击一个小项目的按钮。谁能帮我吗?
async def bottoni(ctx):
await buttons.send(
content = "click!",
channel = ctx.channel.id,
components = [
ActionRow([
Button(
label="first",
style=ButtonType().Success,
custom_id = "button_one"
),
Button(
label="second",
style=ButtonType().Danger,
custom_id = "button_two"
)
])
]
)
@buttons.click
async def button_one(ctx):
interaction = buttons.click
print(interaction.author, " clicked!")
@buttons.click
async def button_two(ctx):
interaction = buttons.click
print(interaction.author, " clicked!")
I'm making a bot for my Discord server, and I'd like to see who clicks the button for a little project. Can anyone help me?
async def bottoni(ctx):
await buttons.send(
content = "click!",
channel = ctx.channel.id,
components = [
ActionRow([
Button(
label="first",
style=ButtonType().Success,
custom_id = "button_one"
),
Button(
label="second",
style=ButtonType().Danger,
custom_id = "button_two"
)
])
]
)
@buttons.click
async def button_one(ctx):
interaction = buttons.click
print(interaction.author, " clicked!")
@buttons.click
async def button_two(ctx):
interaction = buttons.click
print(interaction.author, " clicked!")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
阅读文档

所以这是您的代码
Reading the docs

So here is your code
您可以使用
interaction.user
检索用户,并且可以使用互动。
You can use
interaction.user
to retrieve the user and you can useinteraction.user.id
to get the ID of said user.