#onboard command help
1 messages · Page 1 of 1 (latest)
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
const config = require('../config.json');
var roleID = "";
var memberID = "";
var mentionedmember = "";
var message = "";
var changed = false;
var success = false;
module.exports = {
data: new SlashCommandBuilder()
.setName('onboard')
.setDescription('Specialists use this command to adjust roles for new members.')
.addStringOption(option =>
option.setName('member')
.setDescription('Input the members name here. Use @membername')
.setRequired(true))
.addStringOption(option =>
option.setName('clan')
.setDescription('Input the clan they are moving to. Use @clanmember role')
.setRequired(true)),
async execute(interaction) {
new Promise((resolve, reject) => {
// check if the user has the specialist role
if (!interaction.member.roles.cache.some(role => role.name === 'Specialist')){
message = `You must be a Specialist to use this command.`;
} else if (!interaction.options.getString('member')) {
message = `You did not enter a member name. You must enter the member name and then click out of it so it is highlighted in a black background.`;
} else if (!interaction.options.getString('clan')) {
message = `You did not enter a clan. You must enter the clan member role and then click out of it so it is highlighted in a black background.`;
} else {
// clean up the variables
let clanstr = interaction.options.getString('clan');
roleID = clanstr.substring(3, clanstr.length - 1);
let memberstr = interaction.options.getString('member');
memberID = memberstr.substring(2, memberstr.length - 1);
// get the targeted user info
mentionedmember = interaction.guild.members.cache.get(memberID);
// check the roles for the member
// if member already has the clanmember role, no need to add it (but we'll still check their other roles)
if (mentionedmember.roles.cache.has(roleID)) {
message = `${interaction.options.getString('member')} already has the role ${interaction.options.getString('clan')}.`;
} else {
mentionedmember.roles.add(roleID);
message = `${interaction.options.getString('clan')} role added to ${interaction.options.getString('member')}.`;
changed = true;
}
roleID = "";
success = true;
}
setTimeout(() => resolve(message), 2000);
})
.then(async () => {
if (success){
// remove friend role
roleID = "527897711505178634";
if (mentionedmember.roles.cache.has(roleID)) {
mentionedmember.roles.remove(roleID);
message += `\n<@&527897711505178634> role removed from ${interaction.options.getString('member')}.`;
changed = true;
} else {
message += `\n${interaction.options.getString('member')} does not have the role <@&527897711505178634>`;
}
roleID = "";
}
})
.then(async () => {
if (success){
// add rrclanmember role
// we add this now, instead of up above so that Rylee will send the welcome messages correctly
// when done above, the audit logs are combined and Rylee doesn't send the welcome messages
roleID = "410423114900701214";
if (mentionedmember.roles.cache.has(roleID)) {
message += `\n${interaction.options.getString('member')} already has the role <@&410423114900701214>`;
} else {
mentionedmember.roles.add(roleID);
message += `\n<@&410423114900701214> role added to ${interaction.options.getString('member')}.`;
changed = true;
}
roleID = "";
// if changed is false, these roles were already changed before this command was used.
// if changed is true, this command changed at least one of these roles
if (changed){
// update the member moves channel so we know who used this command
interaction.guild.channels.cache.get(config.MEMBER_MOVE_LOGS_CHANNEL).send(`:green_circle: These roles were adjusted by <@!${interaction.user.id}>.`);
}
}
const sendMemberList = new EmbedBuilder()
.setColor('Blue')
.setTitle(`Onboard Role Change`)
.setDescription(message)
.setFooter({ text: 'Use `/onboard member: @mentionMember clan: @mentionClanMemberRole`'});
await interaction.reply({ embeds: [sendMemberList] });
});
}
};