From 1f504ae0c449b848f51c37f4739df88767539585 Mon Sep 17 00:00:00 2001 From: baz Date: Mon, 18 Dec 2023 21:57:06 +0000 Subject: [PATCH] Create register command --- commands/testing/register.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 commands/testing/register.js 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