亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

機器人發送有關消息而不是消息的信息

機器人發送有關消息而不是消息的信息

慕桂英4014372 2023-03-16 16:11:07
我正在嘗試建立一個系統,當你對表情符號做出反應時,它會將該消息(取決于你做出反應的表情符號)發送到另一個文本通道,現在它返回這個而不是實際的消息:<Message id=733788372891467838 channel=<TextChannel id=733721953134837861 name='admin-bug' position=1 nsfw=False news=False category_id=733717942604398684> type=<MessageType.default: 0> author=<Member id=733720584831369236 name='ReefCraft' discriminator='3102' bot=True nick=None guild=<Guild id=733717942604398682 name="Pumbalo's server" shard_id=None chunked=True member_count=2>> flags=<MessageFlags value=0>>我已經嘗試.content在變量上使用,但它仍然不起作用,并且它給了我錯誤: discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message這是我的代碼:import discordfrom discord.ext import commandsimport asyncioTOKEN = '---'bot = commands.Bot(command_prefix='!!')emojis = ["\u2705", "\U0001F6AB", "\u274C"]@bot.eventasync def on_ready():    print('Bot is ready.')@bot.command()async def bug(ctx, desc=None, rep=None):    user = ctx.author    await ctx.author.send('```Please explain the bug```')    responseDesc = await bot.wait_for('message', check=lambda message: message.author == ctx.author, timeout=300)    description = responseDesc.content    await ctx.author.send('````Please provide pictures/videos of this bug```')    responseRep = await bot.wait_for('message', check=lambda message: message.author == ctx.author, timeout=300)    replicate = responseRep.content    embed = discord.Embed(title='Bug Report', color=0x00ff00)    embed.add_field(name='Description', value=description, inline=False)    embed.add_field(name='Replicate', value=replicate, inline=True)    embed.add_field(name='Reported By', value=user, inline=True)    adminBug = bot.get_channel(733721953134837861)    message = await adminBug.send(embed=embed)    # Add 3 reaction (different emojis) here    for emoji in emojis:        await message.add_reaction(emoji)
查看完整描述

1 回答

?
千萬里不及你

TA貢獻1784條經驗 獲得超9個贊

您必須使用on_raw_reaction_add(), 它返回一個RawReactionActionEvent對象。您將能夠獲得message_id并用于fetch_message最終獲得嵌入:

@bot.event

async def on_raw_reaction_add(payload):

    channel = bot.get_channel(payload.channel_id)

    msg = await channel.fetch_message(payload.message_id)

    embed = msg.embeds[0]

    emoji = payload.emoji


    if user.bot:

        return


    if emoji == "emoji 1":

        fixed = bot.get_channel(733722567449509958)

        await fixed.send(embed=embed)


    elif emoji == "emoji 2":

        notBug = bot.get_channel(733722584801083502)

        await notBug.send(embed=embed)


    elif emoji == "emoji 3":

        notFixed = bot.get_channel(733722600706146324)

        await notFixed.send(embed=embed)


    else:

        return

注意:payload.emoji返回 a discord.PartialEmoji,將其與原始 unicode 進行比較可能不再有效。



查看完整回答
反對 回復 2023-03-16
  • 1 回答
  • 0 關注
  • 119 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號