'Discord.py Massdm
i need this Mass Dm to message everyone except the author But i dont really know how to do it...
@bot.command()
async def massdm(self, ctx, *, args=None):
if args != None:
members = ctx.guild.members
for member in members:
try:
await member.send(args)
print("'" + args + "' sent to: " + member.name)
except:
print("Couldn't send '" + args + "' to: " + member.name)
else:
await ctx.channel.send("A message was not provided.")
Solution 1:[1]
Here is the complete code.
@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}")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
