-2
#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

Bigweld
  • 26
  • 5

2 Answers2

0

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

IPSDSILVA
  • 1,667
  • 9
  • 27
  • sorry, I don't understand. The issue was that it wasn't sending dm messages. What would this solve? – Bigweld Jan 11 '21 at 16:15
  • Although the code does not revolve around DMs (in this post), if there is an issue with the code somewhere, the program may malfunction. – IPSDSILVA Jan 11 '21 at 17:12
0

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}")
Drabmaker
  • 1
  • 3