为什么它不适用于 Python 和 discord.py
Why doesn't it work with Python and discord.py
我正在尝试用 discord.py 做一些简单的事情,比如命令,但它不会在终端或 Discord 中给出任何类似错误的信息。
代码如下:
import discord
from discord.ext import commands
class BotLibertarin(discord.Client):
client = commands.Bot(command_prefix=".")
@client.command()
async def teste(ctx,*,arg):
await ctx.channel.send(arg)
@client.event
async def on_message(self, message):
print(f"message from {message.author} what he said {message.content}")
client = BotLibertarin()
client.run("")
我不确定你的 class 是如何构造的,因为缩进不正确或者你为什么分配 client
两次,但你需要 subclass commands.Bot
to use the commands extension, not Client
.
此外,您需要在 on_message
处理程序中使用 Bot.process_commands
。
参见Why does on_message
make my commands stop working? section of the FAQ in discord.py's documentation。
我正在尝试用 discord.py 做一些简单的事情,比如命令,但它不会在终端或 Discord 中给出任何类似错误的信息。
代码如下:
import discord
from discord.ext import commands
class BotLibertarin(discord.Client):
client = commands.Bot(command_prefix=".")
@client.command()
async def teste(ctx,*,arg):
await ctx.channel.send(arg)
@client.event
async def on_message(self, message):
print(f"message from {message.author} what he said {message.content}")
client = BotLibertarin()
client.run("")
我不确定你的 class 是如何构造的,因为缩进不正确或者你为什么分配 client
两次,但你需要 subclass commands.Bot
to use the commands extension, not Client
.
此外,您需要在 on_message
处理程序中使用 Bot.process_commands
。
参见Why does on_message
make my commands stop working? section of the FAQ in discord.py's documentation。