Eliahs Johansson
Eliahs Johansson

Reputation: 117

How do I make a verification system in Python for Discord Bots?

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':

  1. Check so that you sent the message in a channel with the name 'verify_here'.
  2. If you sent it in that channel, add the "Member" role.
  3. Send message '{message.author}, thank you!'
  4. Delete both messages after 3 seconds.

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

Answers (3)

Jason Martin
Jason Martin

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

Jemeni11
Jemeni11

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 :

  1. It might be your bot permissions. Especially since you are not getting any error messages. Speaking from personal experience here.
  2.    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

x-1-x
x-1-x

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

Related Questions