I am currently trying to get my bot to DM all members of a server when the command :dmall
is sent, but it doesn't appear to work.
My code:
@bot.command()
@commands.is_owner()
async def dmall(ctx,*,message):
for mem in ctx.guild.members:
await ctx.message.delete()
try:
await mem.send(message)
await ctx.send(f'Sent dm to: {mem.name}')
except:
print('User dm closed')
@dmall.error
async def dmall_error(ctx, error):
if isinstance(error, commands.CheckFailure):
await ctx.send('sorry comrade, you arent allowed to do that')