Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

discord.py bot says function doesn't exist while it does

I was about to start making a discord bot with python when it didn’t recognize a function i made.
The first minor problem I found was that when I made my async def on_ready() function, it didn’t print anything while i did tell it to print("Bot is online.").

The second problem is that when I run the command !verify, it throws this error: discord.ext.commands.errors.CommandNotFound: Command "verify" is not found

This is my code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import discord
from discord.ext import commands

client = commands.Bot(command_prefix="!")

async def on_ready():
    print("Bot is online.")

async def verify(ctx):
    role = discord.utils.get(ctx.guild.roles, name="Member")
    if role not in ctx.message.author.roles:
        print("NOT A MEMBER.")
    else:
        print("IS A MEMBER.")

client.run("TOKEN")

>Solution :

You need to add client.command() decorator to let discord.py know that it is a command:

@client.command()
async def verify(ctx):
    role = discord.utils.get(ctx.guild.roles, name="Member")
    if role not in ctx.message.author.roles:
        print("NOT A MEMBER.")
    else:
        print("IS A MEMBER.")

Also write @client.event before your on_ready function because it is a discord.py event.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading