python - 我所有的@client.events 都有效,但我的@client.command 无效,但如果它只是命令和on_ready 事件,@client.command 有效
问题描述
这是我的代码。它仍处于早期开发阶段。另外,我对开发机器人还很陌生。
import discord
from discord.ext import commands
client = discord.Client()
bot_prefix: str = ">"
client = commands.Bot(command_prefix=bot_prefix)
@client.event
async def on_ready():
print('Miska Rise')
这是我现在的一个活动:
@client.event
async def on_message(message):
if message.author == client.user:
return None
if message.content.startswith('woof') or message.content.startswith('Woof'):
await message.channel.send('Bork!')
这是命令:
@client.command()
async def ping(ctx):
await ctx.send('Pong!')
解决方案
如果您覆盖on_message
,则需要调用Bot.process_commands
它,以便仍处理命令。
推荐阅读
- node.js - Discord.js:如何检查是否是人工管理员?
- css - TinyMCE 通知自定义 CSS
- batch-file - 如何让我的 .bat 脚本每 5 分钟运行一次?
- linux - 为什么即使禁用了 d-cache 也需要 DMB 屏障
- c++ - 带有 map_ANON 的 mmap 用于保存大量数据
- python - 在 Pandas 的组中填充以前的值
- javascript - 使用 timestampOffset 的 MediaSource API
- python - 在 Heroku 上托管时,Selenium 应用程序重定向到 Cloudflare 页面
- clojure - 无法在 cljs+clj 项目中运行 clj 文件导致“找不到”
- java - 在 Eclipse 下运行时,BufferedReader 在 StdIn 上看不到文件结尾