From b104dc7e3b7d21b61493b195286c06c90d4a80e1 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Tue, 13 Aug 2024 23:58:05 -0600 Subject: [PATCH] userinfo: add interaction --- src/modules/utility/userinfo.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/modules/utility/userinfo.js b/src/modules/utility/userinfo.js index 1e04b48..bed3e11 100644 --- a/src/modules/utility/userinfo.js +++ b/src/modules/utility/userinfo.js @@ -1,8 +1,10 @@ const Command = require("@lib/command.js"); +const InteractionCommand = require("@lib/interactionCommand.js"); const { ActivityTypeNames, APIEndpoints, + ApplicationCommandOptionTypes, ApplicationFlags, BadgeURLs, CDNEndpoints, @@ -362,3 +364,29 @@ userinfo.callback = async function (msg, line) { return {embeds: [embed]}; }; hf.registerCommand(userinfo); + +const userinfoInteraction = new InteractionCommand("userinfo"); +userinfoInteraction.helpText = "Get information on an user"; +userinfoInteraction.options.id = { + name: "id", + type: ApplicationCommandOptionTypes.STRING, + description: "User ID to get info for", + required: false, + default: "", +}; +userinfoInteraction.options.user = { + name: "user", + type: ApplicationCommandOptionTypes.USER, + description: "User to get info for", + required: false, + default: "", +}; +userinfoInteraction.callback = async function (interaction) { + const id = this.getOption(interaction, "id"); + const user = interaction.resolved?.users + ? Array.from(interaction.resolved.users.keys())[0] + : this.getOption(interaction, "user"); + + return userinfo.callback(interaction, id == "" ? user : id); +}; +hf.registerCommand(userinfoInteraction);