Discord.py command can't be called
Question:
Running this code and running command after on_ready does not print anything in console.
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!', description="This is a Helper Bot")
userasbot = "NoUser"
@bot.command()
async def hello(ctx):
print("Hello")
await ctx.send("Hello, world!")
@bot.event
async def on_ready():
print("Ready!")
bot.run('Token')
Older code I wrote before that has worked before does not do anything too now. Did the library get updated?
Answers:
If you have an on_message(message)
function, you need to process the command using await bot.process_commands(message)
.
Running this code and running command after on_ready does not print anything in console.
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!', description="This is a Helper Bot")
userasbot = "NoUser"
@bot.command()
async def hello(ctx):
print("Hello")
await ctx.send("Hello, world!")
@bot.event
async def on_ready():
print("Ready!")
bot.run('Token')
Older code I wrote before that has worked before does not do anything too now. Did the library get updated?
If you have an on_message(message)
function, you need to process the command using await bot.process_commands(message)
.