Polarcraft/discordbot/commands/adduser.js
2023-08-05 11:16:18 +02:00

29 lines
902 B
JavaScript

const { SlashCommandBuilder } = require('discord.js');
const { simpleEmbed } = require('../functions/embeds.js');
const { Users } = require('../functions/models.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('adduser')
.setDescription('Add a user to the system')
.addUserOption(option => option
.setName('user')
.setDescription('The user to add')),
async execute(interaction) {
const userId = interaction.options.getUser('user') ? interaction.options.getUser('user').id : interaction.user.id;
try {
await Users.create({
id: userId,
});
await interaction.reply({ embeds: [simpleEmbed('Added user to the system')], ephemeral: true });
} catch (error) {
console.error(error);
await interaction.reply({ embeds: [simpleEmbed('There was an error while adding the user')], ephemeral: true });
}
},
};