Python Discord.py-使用反应将嵌入消息发送到另一个通道
因此,我试图让嵌入的信息在不同的文本频道之间传输,有三种选择已修复“-”非错误“-”未修复“。discord服务器的管理员将根据bug的情况从这三个服务器中选择一个 问题是,当我对其中一个表情做出反应时,它会发送有关消息的信息,如下所示:Python Discord.py-使用反应将嵌入消息发送到另一个通道,python,python-3.x,discord.py,discord.py-rewrite,Python,Python 3.x,Discord.py,Discord.py Rewrite,因此,我试图让嵌入的信息在不同的文本频道之间传输,有三种选择已修复“-”非错误“-”未修复“。discord服务器的管理员将根据bug的情况从这三个服务器中选择一个 问题是,当我对其中一个表情做出反应时,它会发送有关消息的信息,如下所示: 我需要它来发送嵌入,所以与其说^^^它应该是这样的: 以下是我的python代码: import discord from discord.ext import commands import asyncio TOKEN = '---' bot = co
我需要它来发送嵌入,所以与其说^^^它应该是这样的:
以下是我的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)
我以前得到过一些帮助,但我从未让它起作用。问题在于您发送的是消息对象,而不是它的内容 您要使用的是
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)
对于初学者,您刚刚公开了您的令牌。请确保立即重新生成一个新的。我认为从上一个问题可以解决您的问题?它最初确实有效,但添加了一些内容,无法使其正常工作。如果我没有记错,这将导致错误
消息没有属性嵌入。您从反应中获得的消息。消息不包括嵌入。@斯帕尔先生啊,是的,我已经更新了它以立即获取消息第一个解决方案似乎很好,第二个解决方案也很好。谢谢!:)