因此,我试图使嵌入消息在不同的文本通道之间传输,这有三个选项。 '固定'-'无臭虫'-'不固定'。不和谐服务器的管理员将根据错误的情况从这三个服务器中选择一个。
问题是,当我对这些表情之一做出反应时,它会发送有关该消息的信息,如下所示:
<Message id=735831838555242557 channel=<TextChannel id=733721953134837861 name='admin-bug' position=4 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>>
我需要它来发送嵌入内容,因此代替它^^应该是这样的:
这是我的python代码:
import discord
from discord.ext import commands
import asyncio
TOKEN = '---'
bot = commands.Bot(command_prefix='!!')
emojis = ["\u2705", "\U0001F6AB", "\u274C"]
emojis2 = ["\u2705", "\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)
@bot.event
async def on_reaction_add(reaction, user):
message = reaction.message
emoji = reaction.emoji
if user.bot:
return
if emoji == "\u2705":
fixed_channel = bot.get_channel(733722567449509958)
await fixed_channel.send(message)
elif emoji == "\U0001F6AB":
notBug = bot.get_channel(733722584801083502)
await notBug.send(message)
elif emoji == "\u274C":
notFixed = bot.get_channel(733722600706146324)
await notFixed.send(message)
else:
return
bot.run(TOKEN)
我之前已经获得了一些帮助,但我从未得到过帮助。
答案 0 :(得分:2)
问题是因为您正在发送消息对象,而不是其内容。
您要使用的是discord.Message.embeds
,以便从邮件中获取嵌入内容。
您可以按照以下原则进行操作:
# your reaction message
reaction_message = reaction.message
#fetch the message
message = await reaction_message.channel.fetch_message(reaction_message.id)
# message.embeds is a list of embeds. Here we get get the first embed which is what you need
my_embed = message.embeds[0]
# now send the embed to the channel
await fixed_channel.send(embed=my_embed)