f5268ace77
commite8a57468deAuthor: Tarrgon <61888458+Tarrgon@users.noreply.github.com> Date: Sat May 31 11:10:56 2025 -0400 Add record command commit5a8ca6bb54Author: Tarrgon <61888458+Tarrgon@users.noreply.github.com> Date: Sat May 31 11:10:30 2025 -0400 Move context menus to their own folder commit2d7c14ed7aMerge:33a6ba85107759Author: Tarrgon <61888458+Tarrgon@users.noreply.github.com> Date: Sat May 31 10:54:27 2025 -0400 Merge branch 'alt-data' into records commit5107759923Author: Tarrgon <61888458+Tarrgon@users.noreply.github.com> Date: Fri May 30 15:26:21 2025 -0400 Recursive alt lookup data
48 lines
2.0 KiB
TypeScript
48 lines
2.0 KiB
TypeScript
import { ApplicationIntegrationType, BitFieldResolvable, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
|
|
import { channelIsInStaffCategory, handleWhoIsInteraction } from '../utils';
|
|
import { getRecordMessageFromDiscordId } from '../utils/record-utils';
|
|
|
|
export default {
|
|
name: 'records',
|
|
data: new SlashCommandBuilder()
|
|
.setName('records')
|
|
.setDescription("Get a user's on-site records.")
|
|
.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)
|
|
),
|
|
handler: async function (client: Client, interaction: ChatInputCommandInteraction) {
|
|
const isStaffChannel = await channelIsInStaffCategory(interaction.channel as GuildBasedChannel);
|
|
|
|
if (isStaffChannel) await interaction.deferReply();
|
|
else await interaction.deferReply({ flags: [MessageFlags.Ephemeral] });
|
|
|
|
if (!interaction.guild) return interaction.editReply('This command must be used in a server');
|
|
|
|
const user = interaction.options.getUser('user');
|
|
const id = interaction.options.getString('id');
|
|
|
|
if (!user && !id) {
|
|
return interaction.reply({ content: 'No user or id given.', flags: [MessageFlags.Ephemeral] });
|
|
}
|
|
|
|
const idToUse = (user?.id ?? id) as string;
|
|
|
|
const recordMessage = await getRecordMessageFromDiscordId(idToUse, 1, interaction.guild);
|
|
|
|
if (!recordMessage) return interaction.editReply('No records found on any linked accounts.');
|
|
|
|
interaction.editReply(recordMessage);
|
|
}
|
|
}; |