From d99ffed3b147dbac0b1d0eb7ecb278ea1a067f9c Mon Sep 17 00:00:00 2001 From: Mikael <46541386+ahnl@users.noreply.github.com> Date: Sat, 6 Jul 2024 17:02:30 +0300 Subject: [PATCH] feat: command for looking up member id --- src/discord/discord.js | 8 ++++++++ src/discord/slashCommands.js | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/discord/discord.js b/src/discord/discord.js index f7ac8f2..f209794 100644 --- a/src/discord/discord.js +++ b/src/discord/discord.js @@ -110,6 +110,14 @@ async function init(database) { .setURL(discordConnectionsURL)) await interaction.reply({ content: "Authorize access to your account by logging in with your Discord account.", components: [row], ephemeral: true }) } + } else if (interaction.commandName === "whois") { + const discordUserId = interaction.options.get("user").value + const member = await database.UserInfo.findOne({ id: discordUserId }, "id") + if (!member) { + await interaction.reply({ content: "Jäsentä ei ole vielä rekisterissä. Yritä huomenna uudelleen.", ephemeral: true }) + return + } + await interaction.reply({ content: member._id.toString(), ephemeral: true }) } } catch (e) { console.error("Failed to process application command", e) diff --git a/src/discord/slashCommands.js b/src/discord/slashCommands.js index b7b6ad9..f46475f 100644 --- a/src/discord/slashCommands.js +++ b/src/discord/slashCommands.js @@ -61,5 +61,17 @@ export default [ ] } ] + }, + { + name: "whois", + description: "Hae käyttäjän jäsentunniste", + options: [ + { + type: 6, + name: "user", + description: "Käyttäjä", + required: true + } + ] } ]