0
import discord
from discord.ext import commands
import platform
import random
import time


bot = commands.Bot(command_prefix='+', case_insensitive=True)


@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}(ID: +{bot.user.id}) |'
      f'Connected to {str(len(bot.guilds))} servers |'
      f'Connected to {str(len(set(bot.get_all_members())))} users')
print('--------')
print('CREATED AND HOSTED BY Fataldagod | Fixed Version')


@bot.event
async def on_command_error(ctx, error):
# Ignore these errors:
ignored = (
    commands.CommandNotFound, commands.UserInputError, commands.BotMissingPermissions, 
commands.MissingPermissions, discord.errors.Forbidden, commands.CommandInvokeError, 
commands.MissingRequiredArgument)
if isinstance(error, ignored):
    return


@bot.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def userinfo(ctx, user: discord.Member):
try:
    embed = discord.Embed(title="{}'s info".format(user.name),
                          description="Here's what I could find.",
                          color=discord.Colour.dark_red())

    embed.add_field(name="Name", value=user.name, inline=True)
    embed.add_field(name="ID", value=user.id, inline=True)
    embed.add_field(name="Status", value=user.status, inline=True)
    embed.add_field(name="Highest role", value=user.top_role)
    embed.add_field(name="Joined", value=user.joined_at)
    embed.set_thumbnail(url=user.avatar_url)

    await ctx.send(embed=embed)
except:
    await ctx.send("Missing Requrired Args")


@commands.has_permissions(administrator=True)
@bot.command(pass_context=True)
async def send(ctx, *, content: str):
for member in ctx.guild.members:
    c = await member.create_dm()
    try:
        await c.send(content)
        await ctx.send("MassDM message sent to: {} ".format(member))
    except Exception:
        await ctx.send("MassDM message blocked by: {} ".format(member))

Was wondering what I can change to make it so the bot DMs specific roles rather than the entire server? For example instead of me typing +send (message) I'd like to type +send @role1 @role2 role3 @role4 (message) or something along these lines.

Any help is much appreciated.

  • This doesn't answer your question, but generally mass DM bots violate discord's developer Terms of Service and can get your account and bots banned from the service. – Rodentman87 Aug 07 '20 at 04:12
  • I understand that, it's for personal use within a personal discord. I'm willing to take the risk. – fataldagod Aug 08 '20 at 03:00
  • You can just replace the part where it grabs the server members with something that will grab a list of members with a role, I'm not sure what the API for that is in discord.py as I don't use it – Rodentman87 Aug 08 '20 at 03:04
  • I'd very much appreciate any help that could resolve my issue. – fataldagod Aug 09 '20 at 22:41

0 Answers0