userinfo: add interaction

This commit is contained in:
Cynthia Foxwell 2024-08-13 23:58:05 -06:00
parent acf37af87a
commit b104dc7e3b

View file

@ -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);