I want to make a command that will send a DM to the entire server, but I am getting the following error:
Forbidden: FORBIDDEN (status code: 403) Can't send messages to this user
What might be causing this?
Here is my current code:
@bot.command(pass_context=True)
async def massdm(ctx, words*):
output = " "
for word in words:
output += word
output += ""
server = ctx.message.server
for member in server.members:
await bot.send_message(member, output)
The user might have blocked your bot or disabled DMs for your server, either way, you won’t be able to salvage the situation, so simply dropping the exception will do.
try:
/* send message */
except Exception:
pass
来源:https://stackoverflow.com/questions/50546847/forbidden-status-code-403-cant-send-messages-to-this-user