所以我有一个紧急命令,以防有什么事情,我必须给每个人发消息,但是机器人有问题,因为给他们发消息会导致错误(机器人角色是“机器人”)
@bot.command(pass_context=True)
async def emergency(ctx, *, message: str):
if admin in [role.id for role in ctx.message.author.roles]:
for server_member in ctx.message.server.members:
await bot.send_message(server_member, message)
else:
await bot.say("DENIED, You do not have permission to use this command")
和错误
Traceback (most recent call last):
File "C:\Users\adamk\PycharmProjects\bot\venv\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "C:\Users\adamk\PycharmProjects\bot\venv\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "C:\Users\adamk\PycharmProjects\bot\venv\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: FORBIDDEN (status code: 403): Cannot send messages to this user