Get all the roles in your server. Slash command format. Go to omg.ac/command and register a slash command named roles.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let event = context.params.event;
await lib.discord.interactions['@1.0.1'].responses.create({
token: `${event.token}`,
response_type: 'DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE',
}); // register the initial response for the slash command
let guild = await lib.discord.guilds['@0.2.4'].retrieve({
guild_id: event.guild_id,
});
let roles = await lib.discord.guilds['@0.2.4'].roles.list({
guild_id: event.guild_id,
}); // retrieving all the roles in server
let list_role = roles
.sort((pA, pB) => {
return pB.position > pA.position ? 1 : -1;
})
.map((role) => {
if (role.name === '@everyone') {
return '@everyone';
}
return `<@&${role.id}>`;
})
.join('\n'); // sorting the roles and then separating one role per line
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: event.channel_id,
content: ``,
embed: {
title: `${roles.length} roles available in the server :`,
type: 'rich',
color: 0x5050aa,
description: list_role,
},
});
await lib.discord.interactions['@1.0.1'].followups.ephemeral.create({
token: `${context.params.event.token}`,
content: `Message sent π½`,
});
// sending the final result ^^