如何在制作不和谐机器人时修复错误?

时间:2017-12-21 22:08:52

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

我正在为我的服务器制作一个discord bot,但是当我尝试使用该命令时,我收到一个错误。

错误:

Loaded Bot Profile:
GloriousBot
393459404290392064
Ignoring exception in command wc
Traceback (most recent call last):
File "C:\Users\chify.DESKTOP-
EASMQIA\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\discord\ext\commands\bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "C:\Users\chify.DESKTOP-
EASMQIA\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\discord\ext\commands\core.py", line 367, in invoke
yield from self.prepare(ctx)
File "C:\Users\chify.DESKTOP-
EASMQIA\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\discord\ext\commands\core.py", line 345, in prepare
yield from self._parse_arguments(ctx)
File "C:\Users\chify.DESKTOP-
EASMQIA\AppData\Local\Programs\Python\Python36-32\lib\site- 
Packages\discord\ext\commands\core.py", line 304, in _parse_arguments
transformed = yield from self.transform(ctx, param)
File "C:\Users\chify.DESKTOP-
EASMQIA\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\discord\ext\commands\core.py", line 212, in transform
raise MissingRequiredArgument('{0.name} is a required argument that is 
missing.'.format(param))
discord.ext.commands.errors.MissingRequiredArgument: user is a required 
argument that is missing.

代码:

https://pastebin.com/GwxNXt9e

进口

import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
import datetime

我试过了,但我是新手,还在学习python。我不确定如何解决此错误。

1 个答案:

答案 0 :(得分:0)

问题是您需要为wc命令指定用户才能工作。 EX:

-wc Vixro

会工作,因为你传递了用户名Vixro。要使其不需要指定用户,请删除

 , user: discord.Member

并添加

user = ctx.message.author

作为wc命令代码的第一行。 希望这有帮助