如何与client.command一起使用on_message?

时间:2020-07-15 12:48:13

标签: python python-3.x discord discord.py discord.py-rewrite

    @client.event
    async def on_message(message):
        await client.process_commands(message)

我不知道该如何使用。

1 个答案:

答案 0 :(得分:0)

上面的代码是完全可以的。如果您尚未定义您的机器人,则必须这样做。 这是您可以根据需要修改的简单代码。

import discord
from discord.ext import commands
bot = commands.Bot(command_prefix = 'YOUR PREFIX')
@bot.command()
async def ling(ctx):
    await ctx.send("Mabel")