obama-bot/commands/truefan.js

41 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-11-28 16:38:23 +00:00
const Discord = require('discord.js');
module.exports.meta = {
name: 'truefan',
aliases: [],
staffOnly: true
}
2020-12-27 12:27:16 +00:00
const roleID = '718862546395988078';
const channelID = '718908301555007518';
2020-11-28 16:38:23 +00:00
/**
*
* @param {Discord.Message} message
* @param {Array<string>} args
*/
2020-11-28 16:38:23 +00:00
module.exports.run = async (message, args) => {
let target = message.mentions.members.first();
2020-12-27 12:27:16 +00:00
let role = message.guild.roles.cache.get(roleID);
let channel = message.guild.channels.cache.get(channelID);
2020-11-28 16:38:23 +00:00
if (!role) return message.channel.send('Error: Could not find role');
if (!channel) return message.channel.send('Error: Could not find channel');
if (!target) return message.channel.send('You need to @mention someone for this to work!');
if (target.user.bot) return message.channel.send('You can\'t do this with bots.');
2020-12-27 12:27:16 +00:00
if (!target.roles.cache.has(roleID)) {
2020-11-28 16:38:23 +00:00
// Give the role
target.roles.add(role);
channel.send(`${target.user} is now able to access this channel.`);
let msg = new Discord.MessageEmbed()
.setTitle('Congratulations!')
2020-12-27 12:27:16 +00:00
.setDescription(`The r/Obamium Discord Staff has decided to give you access to a secret text channel: <#${channelID}>`)
2020-11-28 16:38:23 +00:00
.setThumbnail('https://discordemoji.com/assets/emoji/ClapClap.gif');
target.send(msg);
message.channel.send(`${target.user.username} is now a true obama fan.`);
} else {
// Take the role
target.roles.remove(role);
channel.send(`${target.user} is no longer able to access this channel.`);
message.channel.send(`${target.user.username} is no longer a true obama fan.`);
}
}