如何在Discord服务器中管理所有人? -discord.py

问题描述 投票:0回答:1

当发送命令: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')
discord.py
1个回答
0
投票

没有回溯就无法确定,但是当您无法将DM发送给成员时,这可能会出错。如果成员设置了其隐私设置以不允许服务器成员的DM或阻止了漫游器,则可能会发生这种情况。

您应删除所有可能的异常处理程序,这是一种不好的做法,此特定实例无法确定实际的特定问题并检查回溯。

© www.soinside.com 2019 - 2024. All rights reserved.