[英]discord.py command not responding
代码:
import discord
from discord.ext.commands import Bot
from discord.ext import commands
bot = Bot(command_prefix = ".")
@bot.event
async def on_message(message):
print(message.content)
if message.author == bot.user:
return
if message.content.startswith("hello"):
await message.channel.send('hello!')
@bot.command(name="lol")
async def _lol(ctx):
print("lelele")
print(ctx.author)
await ctx.send("lelele")
覆盖默认提供的on_message
禁止运行任何额外的命令。 为了解决这个问题,添加bot.process_commands(message)
在你的端线on_message
。
import discord
from discord.ext.commands import Bot
from discord.ext import commands
bot = Bot(command_prefix=".")
@bot.event
async def on_message(message):
print(message.content)
if message.author == bot.user:
return
if message.content.startswith("hello"):
await message.channel.send('hello!')
await bot.process_commands(message)
@bot.command(name="lol")
async def _lol(ctx):
print("lelele")
print(ctx.author)
await ctx.send("lelele")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.