3
votes

I need to get @everyone role ID to create a private chat for to server members (I'll restrict others except for those 2 users from reading and sending messages). How?

I tried typing

\@Admin

to get Admin's role ID as an example. But then I typed

\@everyone

and it creates a regular message mentioning everyone on the server (like typing @everyone in chat). No ID.

How do I get @everyone role ID?

3

3 Answers

7
votes

The ID for the everyone role is the Guild ID.
If you try to do <@&123123> replacing 123123 with your guild id, it will almost tag everyone


Update: 10th April 2020

Now to mention everyone, all you need is to send the string @everyone: message.channel.send("@everyone");


To obtain the ID for the everyone role, you need to have the guild, which you get on some events like: message, guildCreate, and others. From there: <something>.guild.roles.everyone, and with that you should be able to get the ID with <something>.guild.roles.everyone.id.

If you don't have access to the guild on a event, you can get the guild by it's ID with something like: client.guilds.cache.get('guildID').roles.everyone.id, if you know that it will be in cache. If you want to be safe, you can do it like this:

client.guilds.fetch('guildID').then(guild => { 
    let id = guild.roles.everyone.id;
    // do something with id
}

or with await:

let guild = await client.guilds.fetch('guildID');
let id = guild.roles.everyone.id;
2
votes

Need to get @everyone Role?

<guild>.roles.everyone

It will get a role object. You can check that in Role Class

2
votes

Discord.js

V12

The guild class has a roles property, which is a RoleManager.
This manager has the property everyone:

The @everyone role of the guild

You can get its id with the id property of the role class:

client.on('message', (msg) => {
  console.log(msg.guild.roles.everyone.id);
});

V11

In V11 the guild class has a defaultRole property.

So the code is slightly different:

client.on('message', (msg) => {
  console.log(msg.guild.defaultRole.id);
});

Discord

On Discord side, with dev option activated, you can right click in almost everything to grab it ID. For example go in the server settings, in role and right click on a role, you should have a copy ID option.