2025-01-11 14:41:57 +00:00
|
|
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
|
|
|
const fn = require('../functions.js');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
data: new SlashCommandBuilder()
|
|
|
|
.setName('setnick')
|
|
|
|
.setDescription('Set a user\'s nickname.')
|
|
|
|
.addUserOption(o =>
|
|
|
|
o.setName('user')
|
|
|
|
.setDescription('The user to set the nickname for.')
|
|
|
|
.setRequired(true)
|
|
|
|
)
|
|
|
|
.addStringOption(o =>
|
|
|
|
o.setName('nickname')
|
|
|
|
.setDescription('The nickname to set.')
|
|
|
|
.setRequired(true)
|
|
|
|
),
|
|
|
|
async execute(interaction) {
|
|
|
|
try {
|
|
|
|
// Defer the reply, with ephemeral set to true
|
|
|
|
await interaction.deferReply({ ephemeral: true });
|
|
|
|
// Get the user and nickname from the interaction
|
|
|
|
const user = interaction.options.getMember('user');
|
|
|
|
const nickname = interaction.options.getString('nickname');
|
|
|
|
|
|
|
|
// Set the nickname
|
|
|
|
await fn.setNick(user, nickname);
|
|
|
|
|
|
|
|
// Reply to the interaction
|
|
|
|
await interaction.editReply(`Successfully set ${user}'s nickname to ${nickname}`);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
2025-01-11 16:02:39 +00:00
|
|
|
if (error.code === 50013) {
|
|
|
|
return await interaction.editReply('I do not have permission to set the nickname of that user!');
|
|
|
|
}
|
|
|
|
if (error.code === 50035) {
|
|
|
|
return await interaction.editReply('The nickname is too long!');
|
|
|
|
}
|
2025-01-11 14:41:57 +00:00
|
|
|
await interaction.editReply('There was an error while executing this command!');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|