代码:
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")
答案 0 :(得分:0)
覆盖提供的默认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")