Advertisements
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:
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.