65 lines
2.4 KiB
JavaScript
65 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
const { time } = require("discord.js");
|
|
|
|
module.exports = {
|
|
name: 'role',
|
|
description: `give or take a role from a user`,
|
|
aliases: ['r'],
|
|
usage: 'role <user> (-)<role>',
|
|
|
|
async execute(client, message) {
|
|
var embed = {
|
|
color: 0x8aa2b3,
|
|
title: '',
|
|
footer: {
|
|
text: `twitter @ ${message.guild.name}`,
|
|
icon_url: client.user.displayAvatarURL(),
|
|
},
|
|
timestamp: new Date(),
|
|
}
|
|
|
|
if (!message.member.permissions.has('Administrator')) {
|
|
embed.description = '<:no:1481811955592466492> you do not have permissions to run this command!';
|
|
await message.reply({ content: null, embeds: [embed] });
|
|
return;
|
|
}
|
|
|
|
if (!message.mentions.members.size) {
|
|
embed.description = '<:no:1481811955592466492> please specify a user to give or take a role from!';
|
|
await message.reply({ content: null, embeds: [embed] });
|
|
return;
|
|
}
|
|
|
|
const member = message.mentions.members.first();
|
|
const roleName = message.content.split(' ').slice(2).join(' ').replace(/^-/, '');
|
|
const role = message.guild.roles.cache.find(r => r.name === roleName);
|
|
|
|
if (!role) {
|
|
embed.description = '<:no:1481811955592466492> role not found!';
|
|
await message.reply({ content: null, embeds: [embed] });
|
|
return;
|
|
}
|
|
|
|
if (message.content.split(' ')[2].startsWith('-')) {
|
|
if (!member.roles.cache.has(role.id)) {
|
|
embed.description = `<:no:1481811955592466492> ${member} does not have the ${role} role!`;
|
|
await message.reply({ content: null, embeds: [embed] });
|
|
return;
|
|
}
|
|
await member.roles.remove(role);
|
|
embed.description = `<:check:1481811973447356496> ${role} role has been taken from ${member}!`;
|
|
} else {
|
|
if (member.roles.cache.has(role.id)) {
|
|
embed.description = `<:no:1481811955592466492> ${member} already has the ${role} role!`;
|
|
await message.reply({ content: null, embeds: [embed] });
|
|
return;
|
|
}
|
|
await member.roles.add(role);
|
|
embed.description = `<:check:1481811973447356496> ${role} role has been given to ${member}!`;
|
|
}
|
|
|
|
await message.reply({ content: null, embeds: [embed] });
|
|
},
|
|
};
|