Reputation: 57
I've started to try coding a discord bot but it was cut short when setting a prefix and events wouldn't work. It just displays an error message that says 'the command "hello" can not be found'.
import discord
from discord.ext import commands
import asyncio
client = commands.Bot(command_prefix="*" ,status=discord.Status.idle, activity=discord.Game("Starting up..."))
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.do_not_disturb, activity=discord.Game("Preparing Puzzle Event"))
print("Bot is running.")
@client.event
async def hello(ctx):
await ctx.send("Hi")
client.run('[The token]')
I know that the token is valid as I've ran it before without assigning a prefix and using 'async'.
Upvotes: 0
Views: 210
Reputation: 578
@client.event
async def hello(ctx):
await ctx.send("Hi")
This won't work because hello
is not a built-in event. See: https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events
What you want is a command probably
@client.command()
async def hello(ctx):
await ctx.send("Hi")
This registers the bot to respond to the command .hello
assuming .
is your prefix
Upvotes: 1