from discord.ext import commands
client = discord.Client(command_prefix='x!')
@client.event
async def on_ready():
print("Successfully booted the bot up!")
@client.event
async def on_message(message):
if message.content.find("minecraft") != -1:
await message.channel.send('@Kerina#4436 ajde majnkraft jebemlite')
@client.command()
async def nwordpass(ctx):
await ctx.send('Proof of you having the nword pass: https://lh3.googleusercontent.com/1HBSAiHdRdM1UVJJZlOUnMkihkiMOPPYSMTjI5WzHuvDVIBztueZR83rkUiHwIJvrfU')
client.run("NzA2MzE0MTc3NjQzNDEzNTY1.Xq4cYw.A-6MruzAgtLC1maW4VVIB2HlFM4")为什么它不起作用?我尝试了几乎所有常见的修复方法,但没有得到任何积极的结果
发布于 2020-05-04 04:45:59
您需要使用discord.ext.commands中的Bot类
from discord.ext import commands
client = commands.Bot(command_prefix='x!')
@client.event
async def on_ready():
print("Successfully booted the bot up!")
@client.event
async def on_message(message):
if message.content.find("minecraft") != -1:
await message.channel.send('@Kerina#4436 ajde majnkraft jebemlite')
await client.process_commands(message)
@client.command()
async def nwordpass(ctx):
await ctx.send('Proof of you having the nword pass: https://lh3.googleusercontent.com/1HBSAiHdRdM1UVJJZlOUnMkihkiMOPPYSMTjI5WzHuvDVIBztueZR83rkUiHwIJvrfU')我还添加了await client.process_commands(message)行,以便处理您的命令。
发布于 2020-05-04 00:06:27
https://discordpy.readthedocs.io/en/latest/ext/commands/extensions.html#id1上的示例代码表明正确的代码如下所示:
@commands.command()
async def nwordpass(ctx):
await ctx.send('Proof of you having the nword pass: https://lh3.googleusercontent.com/1HBSAiHdRdM1UVJJZlOUnMkihkiMOPPYSMTjI5WzHuvDVIBztueZR83rkUiHwIJvrfU')也就是说,command()装饰器是在commands模块上定义的,而不是在Client实例对象上定义的。
https://stackoverflow.com/questions/61577259
复制相似问题