📜  如何检测对消息 discord.py 的反应 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:06.918000             🧑  作者: Mango

代码示例3
@client.event
async def on_message(message):
    #if the spotify command is triggered
        #fetch from the API
        spotifyEmbed = discord.Embed(title=resultName, ...)
        spotifyEmbed.set_image(url=spotifyImgUrl)
        spotifyMessage = await message.channel.send(embed=spotifyEmbed)
        await spotifyMessage.add_reaction("⬅️")
        await spotifyMessage.add_reaction("➡️")

@client.event
async def on_reaction_add(reaction, user):
    if user != client.user:
        if str(reaction.emoji) == "➡️":
            #fetch new results from the Spotify API
            newSearchResult = discord.Embed(...)
            await reaction.message.edit(embed=newSearchResult)
        if str(reaction.emoji) == "⬅️":
            #fetch new results from the Spotify API
            newSearchResult = discord.Embed(...)
            await reaction.message.edit(embed=newSearchResult)