首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >此交互失败- Discord_components - Discord.py

此交互失败- Discord_components - Discord.py
EN

Stack Overflow用户
提问于 2021-07-23 11:56:52
回答 1查看 494关注 0票数 0

你好,我最近用discord_components按钮做了一个帮助命令(我知道Discord.py并不完全支持它们),但我还是继续做了。问题是,每当我运行命令并收到要单击的按钮时,他们总是说“此交互失败”。我好像找不到哪里不对劲。请帮帮忙。

谢谢你NightMX

代码语言:javascript
复制
import discord
from discord.ext import commands
from discord_components.component import ButtonStyle
from discord_components import DiscordComponents, Button, Select, SelectOption
from discord_components.interaction import InteractionType

class BotCommands(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.command()
    async def helpv2(self, ctx):

        funbutton = Button(style=ButtonStyle.grey, label="Fun Commands", id="funcmds")
        monkedevbutton = Button(style=ButtonStyle.grey, label="Attachment Commands", id="monkecmds")
    # utilitybutton = Button(style = ButtonStyle.grey, label = "3", id = "embed3")

        funembed = discord.Embed(title="Fun Commands", colour=discord.Colour.orange())
        funembed.add_field(name="k.joke", value="Sends a Random joke from PyJokes")

        monkedevembed = discord.Embed(title="Fun Commands", colour=discord.Colour.blurple())
        monkedevembed.add_field(name="k.dog", value="Sends a Random Dog Fact")
        monkedevembed.add_field(name="k.monkey", value="Sends a Monkey's Picture")
        monkedevembed.add_field(name="k.bird", value="Sends a Bird's Picture")

        await ctx.send(
            "Kola's Beta Help Command!",
        components=[[funbutton, monkedevbutton]]
    )

        buttons = {
            "funcmds": funembed,
            "monkedcmds": monkedevembed
        }

        while True:
            event = await self.bot.wait_for('button_click')
            if event.channel is not ctx.channel:
                return
            if event.channel == ctx.channel:
                response = buttons.get(event.component.id)

                if response is None:
                    await event.channel.send(
                        "Something went Wrong"
                    )
                if event.channel == ctx.channel:
                    await event.respond(
                        type=InteractionType.ChannelMessageWithSource, embed=response
                    )


def setup(client):
    client.add_cog(BotCommands(client))
EN

回答 1

Stack Overflow用户

发布于 2021-11-09 15:27:30

应为content="something"而不是embed = response

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68493863

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档