0

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

1 Answer 1

1
@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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.