diff --git a/commands/testing/register.js b/commands/testing/register.js new file mode 100644 index 0000000..d63a184 --- /dev/null +++ b/commands/testing/register.js @@ -0,0 +1,25 @@ +const { SlashCommandBuilder } = require('discord.js'); +const { Users } = require ('../../dbObjects.js'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('register') + .setDescription('Manually registers the user into the user database.'), + + async execute(interaction) { + // interaction.user is the object representing the user who ran the command + // interaction.member is the GuildMember object, which represents the user in the specific guild + + const user = await Users.findOne({ where: { discord_id: interaction.user.id } }) + .catch((err) => { + console.log(err); + }); + if (user) return interaction.reply(`User "${interaction.user.username}" is already registered`); + + await Users.create({ discord_id: interaction.user.id, username: interaction.user.username }) + .then(await interaction.reply(`${interaction.user.username} was manually registered.`)) + .catch((err) => { + console.log(err); + }); + }, +}; \ No newline at end of file