Reputation: 117
I'm trying to make a verification system that will work for my Discord Server Network. Here's what I want the bot to do after you type '.agree':
Here's my code:
@client.event
async def on_message(message):
verify_channel = client.get_channel(868120833858621470)
verify_role = get(member.guild.roles, id='871383440694587462')
if message.content == '.agree' in verify_channel:
await member.add_roles(message.author, verify_role)
await message.send(f'{message.author}, thanks!')
The weird part is that I don't get any error messages. It just doesn't work. Nothing is happening. The bot added no role, and the bot sent no message. I've tried searching for help, but there are so few guides on making a verification system for Python Discord Bots. I've also tried different ways of laying out the code, but none has worked.
Note: I will use this Bot and verification system for my whole Discord Server Network meaning I want the bot to check the channel name and not the channel id.
How can I make this work?
Upvotes: 1
Views: 1751
Reputation: 736
You need message.content intent specified in your Bot object as well as it enabled inside of the developer portal for the bot.
Upvotes: 0
Reputation: 1
The weird part is that I don't get any error messages. It just doesn't work. Nothing is happening.
In this case, assuming your code isn't the problem :
verify_channel = client.get_channel(868120833858621470)
verify_role = get(member.guild.roles, id='871383440694587462')
Are you sure these two numbers are correct? Especially the channel id.Upvotes: 0
Reputation: 323
use
if message.content == '.agree' and message.channel == verify_channel:
await member.add_roles(message.author, verify_role)
await message.channel.send(f'{message.author}, thanks!')
instead of
if message.content == '.agree' in verify_channel:
await member.add_roles(message.author, verify_role)
await message.send(f'{message.author}, thanks!')
Hope this makes sense :)
Upvotes: 3