【发布时间】:2019-03-26 00:54:00
【问题描述】:
无论我多么努力,我都找不到有关如何在 Discord.py 中执行此操作的教程,这全是 Discord.js。这是我当前的代码;
@bot.command(brief='announce [message]')
async def announce(ctx, message : str):
print(str(message))
if(str(ctx.message.author) == user):
await ctx.send('User Authentication Successful')
try:
for chan in channels:
try:
channel = bot.get_channel(chan)
info = discord.Embed(title='New Announcement!', description=str(message), color=0xFFFFFF)
await channel.send(embed=info)
except Exception as e:
await ctx.send(e)
await ctx.send("Error: " + str(chan))
except Exception as e:
await ctx.send(e)
这就是我遇到的错误。
Ignoring exception in command announce
Traceback (most recent call last):
File "C:\Users\mashh\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\mashh\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\mashh\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\mashh\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\mashh\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: ctx is a required argument that is missing.
请帮帮我:(
编辑:如果有什么令人困惑的地方,我很抱歉。我正在尝试制作 -announce 命令。在我输入 -announce 的地方,它会宣布(嵌入)输入的任何内容。
【问题讨论】:
-
尝试查看以下问题的答案:stackoverflow.com/questions/51851334/…
-
您使用的是什么版本的 discord.py?你能查一下
discord.__version__吗? -
我正在使用最新版本的 discord.py 和 python 版本 3.6.6
-
如果有什么令人困惑的地方,我很抱歉。我正在尝试制作 -announce 命令。在我输入 -announce
的地方,它会宣布(嵌入)输入的任何内容。
标签: python discord discord.py