#MassDM Command
@bot.command()
async def massdm(ctx, msg):
await ctx.message.delete()
show_cursor()
wipeinput = input(Fore.RED+"Are you sure you want to mass dm? (WARNING: This happens really fast so it will probably flag your account)(y or n): ")
hide_cursor()
if wipeinput == "y" or wipeinput == "Y":
for user in ctx.guild.members:
if user != bot.user:
try:
channel = await user.create_dm()
await channel.send(msg)
print(Fore.GREEN + f'Sent to user "{user.name}"')
except:
print(Fore.YELLOW + f'Failed to DM user "{user.name}"')
pass
print(Fore.GREEN+"Finished")
当我运行这个程序时,它只是说“完成”,什么也不做。当我删除try/except时,它不会出错吗?我想我已经准备好了所有合适的意图
您在这一行中犯了一个错误:
看来你在等待答复。方法是使用
wait_for
函数。您应该将其更改为:此外,我不确定
show_cursor()
和hide_cursor()
是什么函数。它们也可能导致某些东西不起作用编辑:(感谢IPSDSILVA指出这一点)即使我给出的代码没有围绕文章中的问题,代码中的任何问题都可能导致代码无法工作
相关问题 更多 >
编程相关推荐