Here’s the code
import discord import random from discord.ext import commands, tasks from discord.utils import get @client.command() async def play(ctx): red_role = discord.utils.get(ctx.message.guild.roles, name="Red") blue_role = discord.utils.get(ctx.message.guild.roles, name="Blue") red_boss_role = discord.utils.get(ctx.message.server.roles, name="Red Boss") blue_boss_role = discord.utils.get(ctx.message.server.roles, name="Blue Boss")
and then DMing
for i in red_boss_role_id.members: await i.send("🔴" + str(red_agents)) for i in blue_boss_role_id.members: await i.send("🔵" + str(blue_agents))
I have already tried same thing with IDs, but no progress It says the error
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'server'
Advertisement
Answer
I believe your problem is you are using server
, as it is not defined, it is giving you an error AttributeError: 'Message' object has no attribute 'server'
and it states it is not an attribute of message.
red_role
and blue_role
both were using guild
, I’ve changed the ones below to guild, hopefully this works for you
@client.command() async def play(ctx): red_role = discord.utils.get(ctx.message.guild.roles, name="Red") blue_role = discord.utils.get(ctx.message.guild.roles, name="Blue") red_boss_role = discord.utils.get(ctx.message.guild.roles, name="Red Boss") blue_boss_role = discord.utils.get(ctx.message.guild.roles, name="Blue Boss")