discord python reaction channel code example

Example 1: discord bot python on reaction

@client.event
async def on_reaction_add(reaction, user):
    # Steals your reaction by removing the original and adding it's own
    if not user.bot and reaction.message.content == "try me":
        await reaction.remove(user)
        await reaction.message.add_reaction(reaction.emoji)

Example 2: on message discord py

@bot.event
async def on_message(message):
    if message.content == "pong":
        await message.channel.send('ping')

Example 3: get guild from a channel discord py

channel.guild