按钮嵌入(Discord.py)



我一直在尝试制作一个假的硝基命令。我在嵌入下做了一个接受按钮,将用户带到一个链接(可能是一个巨魔GIF图像或图片)。

当前,这是代码。

import discord
from discord.ext import commands
from discord_components import *
from discord_buttons_plugin import *

def __init__(self, client):
self.client = client
buttons = ButtonsClient(client)

@commands.command(name='nitro')
@commands.has_permissions(ban_members=True)
async def nitro(self,ctx, member: discord.Member = None):
if member == None:
member = ctx.author

embed = discord.Embed(title = "**You've been gifted a subscription!**",
description = f"||**{member.mention}**|| has gifted you Nitro for **1 month!**",
color = 0xc17ce0)
embed.set_image(url = 'https://media.threatpost.com/wp-content/uploads/sites/103/2021/04/19145523/Discord-Nitro-e1618858537976.png' )
await buttons.send(
content = None,
embed = embed,
channel = ctx.channel.id,
components = [
ActionRow([
Button(
style = ButtonType().Link,
label = "Accept",
url = "https://c.tenor.com/Bvb1iMhQQUUAAAAC/gorilla-middle-finger.gif"
)
])
]
)

没有显示任何错误,但是命令不工作。我该怎么做呢?

这些是类似于discord.py的第三方api。要使用Discord .py中的交互和按钮,您可以使用Discord的主版本,可以通过以下方式下载:

pip install -U git+https://github.com/Rapptz/discord.py

有关的支持将在他们的官方支持服务器上提供。

最新更新