第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

Discord.Py 向嵌入消息添加反應(yīng)

Discord.Py 向嵌入消息添加反應(yīng)

海綿寶寶撒 2023-03-16 11:03:39
因此,我正在嘗試向機器人在文本通道中發(fā)送的消息添加三種不同的反應(yīng)(表情符號)。用戶在他們的 DM 中填寫一個表格,然后消息被發(fā)送到一個名為“admin-bug”的文本通道,然后服務(wù)器的管理員可以對三種不同的表情符號做出反應(yīng):固定的不會被修復(fù)不是錯誤然后,根據(jù)管理員按下的表情符號,消息將被傳輸?shù)轿谋绢l道。但!我似乎無法弄清楚您實際上是如何將反應(yīng)添加到消息本身的,我已經(jīng)進行了大量的谷歌搜索,但找不到答案。代碼:import discordfrom discord.ext import commandsTOKEN = '---'bot = commands.Bot(command_prefix='!!')reactions = [":white_check_mark:", ":stop_sign:", ":no_entry_sign:"]@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)    await adminBug.send(embed=embed)    # Add 3 reaction (different emojis) herebot.run(TOKEN)
查看完整描述

4 回答

?
白豬掌柜的

TA貢獻1893條經(jīng)驗 獲得超10個贊

Messagable.send返回它發(fā)送的消息。因此,您可以使用該消息對象向其添加反應(yīng)。簡單地說,您必須使用變量來定義機器人發(fā)送的消息。


embed = discord.Embed(title="Bug report")

embed.add_field(name="Name", value="value")

msg = await adminBug.send(embed=embed)

您可以使用msg添加對該特定消息的反應(yīng)


await msg.add_reaction("??")

閱讀 discord.py 文檔以獲取詳細信息。


Message.add_reaction


查看完整回答
反對 回復(fù) 2023-03-16
?
慕森卡

TA貢獻1806條經(jīng)驗 獲得超8個贊

discord.py 文檔有一個關(guān)于添加反應(yīng)的常見問題解答帖子,它有多個示例和深入的描述,此外還Messageable.send返回發(fā)送的消息,以便您可以使用Message.add_reaction它。https://discordpy.readthedocs.io/en/neo-docs/faq.html#how-can-i-add-a-reaction-to-a-message


查看完整回答
反對 回復(fù) 2023-03-16
?
MMTTMM

TA貢獻1869條經(jīng)驗 獲得超4個贊

您需要將嵌入保存為變量,這樣您就可以添加反應(yīng)。


message = await adminBug.send(embed=embed)  # save embed as "message"

await message.add_reaction('xxx')           # add reaction to "message"


查看完整回答
反對 回復(fù) 2023-03-16
?
絕地?zé)o雙

TA貢獻1946條經(jīng)驗 獲得超4個贊

我不確定,因為我使用的是 nextcord(并且有效),但我認為這可行:


@bot.command

async def testembed(ctx):

    embed = discord.Embed(title='Test !', description='This is a test embed !')

    msg = await ctx.send("", embed=embed)

    msg = msg.fetch()   # Notice this line ! It's important !

    await msg.add_reaction('emoji_id')


查看完整回答
反對 回復(fù) 2023-03-16
  • 4 回答
  • 0 關(guān)注
  • 121 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號