Skip to content

Instantly share code, notes, and snippets.

@theimpossiblequiz
Created December 9, 2020 01:56
Show Gist options
  • Save theimpossiblequiz/665d79fd4ec2a04a14fcbd85841d8682 to your computer and use it in GitHub Desktop.
Save theimpossiblequiz/665d79fd4ec2a04a14fcbd85841d8682 to your computer and use it in GitHub Desktop.
reaction roles
module.exports = {
name: 'reactionrole',
description: "Sets up a reaction role message!",
async execute(message, args, Discord, client) {
const channel = '786004704621756426';
const verifiedRole = message.guild.roles.cache.find(role => role.name === "squad bois");
const dmopenRole = message.guild.roles.cache.find(role => role.name === "DM's Open");
const dmclosedRole = message.guild.roles.cache.find(role => role.name === "DM's Closed");
const beatsaberplayerRole = message.guild.roles.cache.find(role => role.name === "Beat Saber Player");
const gamerRole = message.guild.roles.cache.find(role => role.name === "Gamer");
const naRole = message.guild.roles.cache.find(role => role.name === "North America");
const eaRole = message.guild.roles.cache.find(role => role.name === "Europe");
const ausRole = message.guild.roles.cache.find(role => role.name === "Australia");
const spotifyRole = message.guild.roles.cache.find(role => role.name === "Spotify Listener");
//reaction role emoji const
const verifiedRoleEmoji = '☑️';
const dmopenRoleEmoji = '🔔';
const dmclosedRoleEmoji = '🔕';
const beatsaberplayerRoleEmoji = '731797140573126686';
const gamerRoleEmoji = '🎮';
const naRoleEmoji = '786015637289828362';
const eaRoleEmoji = '786015653152161852';
const ausRoleEmoji = '786015667656589353'
const spotifyRoleEmoji = '776618058915512330';
let embed1 = new Discord.MessageEmbed()
.setColor('#e42643')
.setTitle('Identifier Roles')
.setAuthor('Comrade Pengwin', 'https://i.imgur.com/lyruSKP.jpeg', 'https://discord.js.org')
.setDescription('These are identifier roles, they tell other user what you want/like!\n\n'
+ `${verifiedRoleEmoji} for the verified role,\n\n`
+ `${dmopenRoleEmoji} for the DM's open role,\n\n`
+ `${dmclosedRoleEmoji} for the DM's closed role,\n\n`
+ `${beatsaberplayerRoleEmoji} for the Beat Saber Player role,\n\n`
+ `${gamerRoleEmoji} for the Gamer role,\n\n`
)
.setThumbnail('https://i.imgur.com/lyruSKP.jpeg', 'https://discord.js.org')
.setFooter('Made by Theimpossiblequiz#6969 & LazySensy#1075', 'https://i.imgur.com/iGY5LBj.png', 'https://discord.js.org');
let messageEmbed1 = await message.channel.send(embed1);
messageEmbed1.react(verifiedRoleEmoji);
messageEmbed1.react(dmopenRoleEmoji);
messageEmbed1.react(dmclosedRoleEmoji);
messageEmbed1.react(beatsaberplayerRoleEmoji);
messageEmbed1.react(gamerRoleEmoji);
let embed2 = new Discord.MessageEmbed()
.setColor('#00FFF4')
.setTitle('Region Roles')
.setAuthor('Comrade Pengwin', 'https://i.imgur.com/lyruSKP.jpeg', 'https://discord.js.org')
.setDescription('This tells other user of the server what Region you are in!\n\n'
+ `${naRoleEmoji} for the North America role,\n\n`
+ `${eaRoleEmoji} for the Europe role,\n\n`
+ `${ausRoleEmoji} for the Australia role,\n\n`
)
.setThumbnail('https://i.imgur.com/lyruSKP.jpeg', 'https://discord.js.org')
.setFooter('Made by Theimpossiblequiz#6969 & LazySensy#1075', 'https://i.imgur.com/iGY5LBj.png', 'https://discord.js.org');
let messageEmbed2 = await message.channel.send(embed2);
messageEmbed2.react(naRoleEmoji);
messageEmbed2.react(eaRoleEmoji);
messageEmbed2.react(ausRoleEmoji);
let embed3 = new Discord.MessageEmbed()
.setColor('#1EFF00')
.setTitle('Music Roles')
.setAuthor('Comrade Pengwin', 'https://i.imgur.com/lyruSKP.jpeg', 'https://discord.js.org')
.setDescription('This tells other user what you use to listen to music!\n\n'
+ `${spotifyRoleEmoji} for the Spotify role,\n\n`
)
.setThumbnail('https://i.imgur.com/lyruSKP.jpeg', 'https://discord.js.org')
.setFooter('Made by Theimpossiblequiz#6969 & LazySensy#1075', 'https://i.imgur.com/iGY5LBj.png', 'https://discord.js.org');
let messageEmbed3 = await message.channel.send(embed3);
messageEmbed3.react(spotifyRoleEmoji);
client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.id == channel) {
if (reaction.emoji.name === verifiedRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(verifiedRole);
}
if (reaction.emoji.name === dmopenRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(dmopenRole);
}
if (reaction.emoji.name === dmclosedRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(dmclosedRole);
}
if (reaction.emoji.name === beatsaberplayerRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(beatsaberplayerRole);
}
if (reaction.emoji.name === gamerRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(gamerRole);
}
if (reaction.emoji.name === naRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(naRole);
}
if (reaction.emoji.name === eaRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(eaRole);
}
if (reaction.emoji.name === ausRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(ausRole);
}
if (reaction.emoji.name === spotifyRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(spotifyRole);
}
} else {
return;
}
});
client.on('messageReactionRemove', async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.id == channel) {
if (reaction.emoji.name === verifiedRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(verifiedRole);
}
if (reaction.emoji.name === dmopenRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(dmopenRole);
}
if (reaction.emoji.name === dmclosedRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(dmclosedRole);
}
if (reaction.emoji.name === beatsaberplayerRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(beatsaberplayerRole);
}
if (reaction.emoji.name === gamerRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(gamerRole);
}
if (reaction.emoji.name === naRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(naRole);
}
if (reaction.emoji.name === eaRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(eaRole);
}
if (reaction.emoji.name === ausRoleEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(ausRole);
}
if (reaction.emoji.name === spotifyRole) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(spotifyRole);
}
} else {
return;
}
});
}
}
@DamagedVU
Copy link

If you're having an issue with your custom emoji's not wanting to load in the Embed, I would highly suggest changing it to as such;
const beatsaberplayerRoleEmoji = '<:emotename:731797140573126686>';

That will fix your emoji issue. Other than that, this script works flawless!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment