机器人发送有关消息而不是消息的信息

我正在尝试建立一个系统,当你对表情符号做出反应时,它会将该消息(取决于你做出反应的表情符号)发送到另一个文本通道,现在它返回这个而不是实际的消息:


<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 discord

from discord.ext import commands

import asyncio


TOKEN = '---'

bot = commands.Bot(command_prefix='!!')


emojis = ["\u2705", "\U0001F6AB", "\u274C"]



@bot.event

async 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)



慕桂英4014372
浏览 87回答 1
1回答

千万里不及你

您必须使用on_raw_reaction_add(), 它返回一个RawReactionActionEvent对象。您将能够获得message_id并用于fetch_message最终获得嵌入:@bot.eventasync def on_raw_reaction_add(payload):&nbsp; &nbsp; channel = bot.get_channel(payload.channel_id)&nbsp; &nbsp; msg = await channel.fetch_message(payload.message_id)&nbsp; &nbsp; embed = msg.embeds[0]&nbsp; &nbsp; emoji = payload.emoji&nbsp; &nbsp; if user.bot:&nbsp; &nbsp; &nbsp; &nbsp; return&nbsp; &nbsp; if emoji == "emoji 1":&nbsp; &nbsp; &nbsp; &nbsp; fixed = bot.get_channel(733722567449509958)&nbsp; &nbsp; &nbsp; &nbsp; await fixed.send(embed=embed)&nbsp; &nbsp; elif emoji == "emoji 2":&nbsp; &nbsp; &nbsp; &nbsp; notBug = bot.get_channel(733722584801083502)&nbsp; &nbsp; &nbsp; &nbsp; await notBug.send(embed=embed)&nbsp; &nbsp; elif emoji == "emoji 3":&nbsp; &nbsp; &nbsp; &nbsp; notFixed = bot.get_channel(733722600706146324)&nbsp; &nbsp; &nbsp; &nbsp; await notFixed.send(embed=embed)&nbsp; &nbsp; else:&nbsp; &nbsp; &nbsp; &nbsp; return注意:payload.emoji返回 a&nbsp;discord.PartialEmoji,将其与原始 unicode 进行比较可能不再有效。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python