gpt4 book ai didi

python - Discord 丰富的嵌入按钮

转载 作者:太空宇宙 更新时间:2023-11-03 13:56:19 27 4
gpt4 key购买 nike

我制作了一些 discord.py 机器人,但我遇到了一个令人惊讶的机器人。它称为 IdleRPG,使用带有按钮的丰富嵌入消息。这是一张照片(请注意菜单底部的按钮):

enter image description here

我已经尝试联系开发人员并一直在网上搜索,但似乎无法找到他们是如何做到的。有谁知道有关如何创建它们的任何资源?请提供链接。

最佳答案

更新:请检查this回答最新版本的 discord.py


给你......我能够创建一个命令来编辑响应点击的嵌入:

程序:

@client.command()
async def embedpages():
page1 = discord.Embed (
title = 'Page 1/3',
description = 'Description',
colour = discord.Colour.orange()
)
page2 = discord.Embed (
title = 'Page 2/3',
description = 'Description',
colour = discord.Colour.orange()
)
page3 = discord.Embed (
title = 'Page 3/3',
description = 'Description',
colour = discord.Colour.orange()
)

pages = [page1, page2, page3]

message = await client.say(embed = page1)

await client.add_reaction(message, '⏮')
await client.add_reaction(message, '◀')
await client.add_reaction(message, '▶')
await client.add_reaction(message, '⏭')

i = 0
emoji = ''

while True:
if emoji == '⏮':
i = 0
await client.edit_message(message, embed = pages[i])
elif emoji == '◀':
if i > 0:
i -= 1
await client.edit_message(message, embed = pages[i])
elif emoji == '▶':
if i < 2:
i += 1
await client.edit_message(message, embed = pages[i])
elif emoji == '⏭':
i = 2
await client.edit_message(message, embed=pages[i])

res = await client.wait_for_reaction(message = message, timeout = 30.0)
if res == None:
break
if str(res[1]) != '<Bots name goes here>': #Example: 'MyBot#1111'
emoji = str(res[0].emoji)
await client.remove_reaction(message, res[0].emoji, res[1])

await client.clear_reactions(message)

截图:

enter image description here

要接受页码,您必须为该表情符号创建一个 if 语句并使用 wait_for_message() 函数。然后您必须检查页码是否有效并相应地更改 i 的值。

我希望你明白这一点。

关于python - Discord 丰富的嵌入按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55075157/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com