Running on py-cord 2.0.0, I am trying to have my bot send a message that mentions @everybody.
import discord
import os
from discord.ext import commands, tasks
prefix = os.getenv('PREFIX')
intents = discord.Intents.all()
bot = discord.Bot(command_prefix=prefix, intents=intents)
@ bot.slash_command(description="Test command, just sends a message where the user requested.")
async def say(ctx):
UserNAME = ctx.author.name
NickNAME = ctx.author.nick
guildNAME = ctx.guild.name
if ctx.user.nick:
UserNAME = NickNAME
await ctx.send(f"Hello! <@{ctx.author.id}>")
await ctx.send(content=f"Hello! <@&915760331165429781>")
bot.run(os.getenv('TOKEN'))
The bot sends both messages, but when it is sending the second message, it does not actually mention the everyone role. I get a message that is "Hello! @@everyone" and this does not function as a mention.
CodePudding user response:
You can try something like this:
async def say(ctx):
guild = ctx.guild
everyone_role = guild.default_role
await ctx.send(f'{everyone_role.mention}')
using default_role
and mention