当发送命令:dmall时,我目前正试图让我的机器人DM服务器的所有成员,但似乎不起作用。
我的代码:
@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')
没有回溯就无法确定,但是当您无法将DM发送给成员时,这可能会出错。如果成员设置了其隐私设置以不允许服务器成员的DM或阻止了漫游器,则可能会发生这种情况。
您应删除所有可能的异常处理程序,这是一种不好的做法,此特定实例无法确定实际的特定问题并检查回溯。