【发布时间】:2021-02-17 21:23:40
【问题描述】:
我刚刚开始编写不和谐机器人。在尝试遵循在线说明和教程时,我的机器人不会响应命令。它对 on_message() 的响应非常好,但无论我尝试什么,它都不会响应命令。我确信这很简单,但我会很感激你的帮助。
import discord
from discord.ext.commands import Bot
from discord.ext import commands
bot = commands.Bot(command_prefix='$')
TOKEN = '<token-here>'
@bot.event
async def on_ready():
print(f'Bot connected as {bot.user}')
@bot.event
async def on_message(message):
if message.content == 'test':
await message.channel.send('Testing 1 2 3')
@bot.command(name='go')
async def dosomething(ctx):
print("command called") #Tried putting this in help in debugging
await message.channel.send("I did something")
bot.run(TOKEN)
【问题讨论】:
标签: python command discord bots