Reputation: 17
I am trying to create a Discord bot and add some commands to it but it seems to not work. I added the print statement to figure out if the command was added, but it returns None. Calling "!hello" in the Discord channel raises CommandNotFound.
import discord
from discord.ext import commands
client = commands.Bot(command_prefix="!")
TOKEN = [some token]
@client.command
async def hello(ctx, arg):
await ctx.channel.send(arg)
print(client.get_command("hello"))
client.run(TOKEN)
Upvotes: -1
Views: 289
Reputation: 209
ctx.channel.send() needs to be replaced by ctx.send() and as loloToster just said, @client.command needs () behind it so the final code would be:
from discord.ext import commands
client = commands.Bot(command_prefix="!")
TOKEN = [some token]
@client.command()
async def hello(ctx, arg):
await ctx.send(arg)
print(client.get_command("hello"))
client.run(TOKEN)
Upvotes: 2
Reputation: 1413
That's because you are missing parentheses after @client.command
, just add ()
to it like this:
@client.command()
Upvotes: 4