Skip to content

Instantly share code, notes, and snippets.

@funnbot
Created December 27, 2016 02:57
Show Gist options
  • Save funnbot/787b6a0f0527ba1348912cac55c9d747 to your computer and use it in GitHub Desktop.
Save funnbot/787b6a0f0527ba1348912cac55c9d747 to your computer and use it in GitHub Desktop.
This is my colorme command for my bot MopBot.
const misc = require('../../Functions/misc');
exports.exec = (message, bot, suffix, param) => {
let colors = {
red: "#ff0000",
darkred: "#730000",
pink: "#FC10EC",
orange: "#ff7300",
yellow: "#ffff00",
blue: "#0000ff",
darkblue: "#000577",
lightblue: "#00d1ff",
turquoise: "#00ffb3",
green: "#00ff00",
darkgreen: "#00af17",
lightgreen: "#9aff4b",
purple: "#9000d4",
magenta: "#400245",
black: "#100000",
gray: "#8e8b8c",
white: "#ffffff"
};
if (param[1] === "reset") {
message.member.roles.forEach(r => {
if (r.name.startsWith('colorme=')) {
if (r.members.size === 1) r.delete();
if (r.members.size > 1) message.member.removeRole(r);
}
});
return;
}
if (!colors.hasOwnProperty(param[1])) return misc.sendError(message, "That is not a valid color. \nTry: red | darkred | pink | orange | yellow | blue | darkblue | lightblue | turquoise | green | darkgreen | lightgreen | purple | magenta | black | gray | white", 10000);
if (message.guild.member(bot.user).highestRole.position > message.member.highestRole.position) {
let memroles = message.member.roles.filter(r => r.name.startsWith('colorme='));
if (memroles.size > 0) memroles.forEach(r => {
if (r.members.size === 1) r.delete();
if (r.members.size > 1) message.member.removeRole(r);
})
if (message.guild.roles.exists('name', 'colorme=' + param[1])) {
let r = message.guild.roles.find('name', 'colorme=' + param[1])
if (r.position > message.member.highestRole.position) {
return message.member.addRole(r);
} else {
r.setPosition(message.member.highestRole.position + 1);
return message.member.addRole(r);
}
} else {
message.guild.createRole({
name: "colorme=" + param[1],
color: colors[param[1]].toUpperCase()
}).then(r => {
r.setPosition(message.member.highestRole.position + 1).catch(err => console.log(err))
message.member.addRole(r);;
});
}
let clean = message.guild.roles.filter(r => r.name.startsWith('colorme='));
clean.forEach(r => {
if (r.members.size === 0) r.delete();
})
} else {
misc.sendWarn(message, "I cannot make a role higher than yours.", 5000)
}
}
exports.conf = {
coolDown: 500,
category: "Fun",
alias: "cme",
deleteCommand: true,
perm: 0,
botPerm: ["SEND_MESSAGES", "MANAGE_ROLES_OR_PERMISSIONS"]
}
exports.help = {
help: "Change the color of your name",
helpExt: "Creates a new role thats positioned above your highest role, to change the color of your name. Available colors: \n`red | darkred | pink | orange | yellow | blue | darkblue | lightblue | turquoise | green | darkgreen | lightgreen | purple | magenta | black | gray | white`",
args: "<color>"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment