Reputation: 26
#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")
When I run this it just says "Finished" and doesnt do anything. when i remove the try/except it gives not error? I have all the proper intents set up i think
Upvotes: -2
Views: 285
Reputation: 1
Here is the full code with everything working.
@client.command(pass_context=True)
async def massdm(ctx):
await ctx.message.delete()
for member in list(client.get_all_members()):
try:
embed = discord.Embed(title="Test",
description="Test!",
color=discord.Colour.blurple())
embed.set_thumbnail(
url="test")
embed.set_footer(
text=
"test"
)
await asyncio.sleep(30)
await member.send(embed=embed)
except:
pass
#await ctx.send(f"Messaged: {member.name}")
print(f"Messaged: {member.name}")
Upvotes: 0
Reputation: 34
You're making a mistake in this line:
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): ")
It seems that you're waiting for a response. The way to do that is with the wait_for
function. You should change that to this:
await ctx.send("Are you sure you want to mass dm? (WARNING: This happens really fast so it will probably flag your account)(y or n)?")
wipeinput = bot.wait_for('message') # You can add another parameter to check if the input is valid and what you want.
In addition, I am unsure of what the functions show_cursor()
and hide_cursor()
are. They may also be causing something to not work.
EDIT: (Thanks to IPSDSILVA for pointing this out) Even though the code that I gave doesn't revolve around the issue in the post, any issue in the code may cause your code to not work
Upvotes: 0