Use resolveUser with whois
This commit is contained in:
@@ -23,8 +23,8 @@ export default {
|
||||
const matches = mentionRegex.exec(input);
|
||||
mentionRegex.lastIndex = 0;
|
||||
|
||||
const idToUse = matches ? matches.groups!.id : input;
|
||||
const valueToUse = matches ? matches.groups!.id : input;
|
||||
|
||||
handleWhoIsInteraction(interaction, idToUse, !(await channelIsInStaffCategory(interaction.channel as GuildBasedChannel)));
|
||||
handleWhoIsInteraction(interaction, valueToUse, !(await channelIsInStaffCategory(interaction.channel as GuildBasedChannel)));
|
||||
}
|
||||
};
|
||||
+8
-5
@@ -1,15 +1,18 @@
|
||||
import { CommandInteraction, MessageFlags } from 'discord.js';
|
||||
import { config } from '../config';
|
||||
import { Database } from '../shared/Database';
|
||||
import { getE621Alts } from './alt-utils';
|
||||
import { resolveUser } from './discord-user-utils';
|
||||
|
||||
export async function handleWhoIsInteraction(interaction: CommandInteraction, idToUse: string, ephemeral = false) {
|
||||
export async function handleWhoIsInteraction(interaction: CommandInteraction, valueToUse: string, ephemeral = false) {
|
||||
if (ephemeral) await interaction.deferReply({ flags: [MessageFlags.Ephemeral] });
|
||||
else await interaction.deferReply();
|
||||
|
||||
if (!interaction.guild) return interaction.editReply('This command must be used in a server');
|
||||
|
||||
const content = await getE621Alts(idToUse, interaction.guild!);
|
||||
const user = await resolveUser(interaction.client, valueToUse, interaction.guild);
|
||||
|
||||
interaction.editReply(`<@${idToUse}>'s e621 and discord account(s):\n${content}`);
|
||||
if (!user) return interaction.editReply('User not found.');
|
||||
|
||||
const content = await getE621Alts(user.id, interaction.guild!);
|
||||
|
||||
interaction.editReply(`<@${user.id}>'s e621 and discord account(s):\n${content}`);
|
||||
}
|
||||
Reference in New Issue
Block a user