I would like my discord bot to respond with a certain message back within a server based on the reaction given by the user: either or .
I am not too familiar with discord.py and the docs I have read are slightly confusing, I followed a youtube tutorial and made edits. I get to see the reaction printed in the console, however I get the error message:
Instance of 'Bot' has no 'channel' member
Here is my code:
import os
import datetime
import discord
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
client = commands.Bot(command_prefix = '!')
@client.event
async def on_ready():
print('Bot is logged in.')
@client.command(name='feedback', help='Ask person for feedback')
async def roll(ctx):
await ctx.send('Are you enjoying this bot? \n :thumbsup: :-1: ')
@client.event
async def on_raw_reaction_add(reaction, user):
print(reaction.emoji)
channel = reaction.message.channel
await client.channel.send_message(channel, reaction.emoji)
if reaction.emoji == ':thumbsup:':
await client.channel.send_message(channel, 'Thank you for your feedback')
elif reaction.emoji == ':-1:':
await client.channel.send_message(channel, 'Sorry you feel that way')
client.run(TOKEN)
All help greatly appreciated