Remove optionals from whois and finduser

This commit is contained in:
Tarrgon
2025-06-04 15:08:08 -04:00
parent bf21e9b423
commit 417cc02bbd
2 changed files with 15 additions and 32 deletions
+10 -16
View File
@@ -1,6 +1,8 @@
import { ApplicationIntegrationType, BitFieldResolvable, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
import { ApplicationIntegrationType, BitFieldResolvable, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, MessageMentions, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
import { channelIsInStaffCategory, handleWhoIsInteraction } from '../utils';
const mentionRegex = new RegExp(MessageMentions.UsersPattern);
export default {
name: 'whois',
data: new SlashCommandBuilder()
@@ -9,27 +11,19 @@ export default {
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall)
.setContexts(InteractionContextType.Guild)
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
.addUserOption(option =>
option
.setName('user')
.setDescription('The discord user to find the e621 user of.')
.setRequired(false)
)
.addStringOption(option =>
option
.setName('id')
.setDescription('The discord user id to find the e621 user of.')
.setRequired(false)
.setName('user')
.setDescription('The discord user mention, or ID to find the e621 user of.')
.setRequired(true)
),
handler: async function (client: Client, interaction: ChatInputCommandInteraction) {
const user = interaction.options.getUser('user');
const id = interaction.options.getString('id');
const input = interaction.options.getString('user', true);
if (!user && !id) {
return interaction.reply({ content: 'No user or id given.', flags: [MessageFlags.Ephemeral] });
}
const matches = mentionRegex.exec(input);
mentionRegex.lastIndex = 0;
const idToUse = (user?.id ?? id) as string;
const idToUse = matches ? matches.groups!.id : input;
handleWhoIsInteraction(interaction, idToUse, !(await channelIsInStaffCategory(interaction.channel as GuildBasedChannel)));
}