diff --git a/src/commands/link.ts b/src/commands/link.ts index c2f9ec9..7e576a4 100644 --- a/src/commands/link.ts +++ b/src/commands/link.ts @@ -1,4 +1,4 @@ -import { ApplicationIntegrationType, BitFieldResolvable, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, MessageMentions, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js'; +import { ApplicationIntegrationType, BitFieldResolvable, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, MessageMentions, PermissionFlagsBits, SlashCommandBuilder, User } from 'discord.js'; import { channelIsInStaffCategory, handleWhoIsInteraction, logCustomEvent } from '../utils'; import { Database } from '../shared/Database'; import { config } from '../config'; @@ -59,7 +59,13 @@ export default { const idToUse = matches ? matches.groups!.id : discordUserInput; - const user = await client.users.fetch(idToUse); + let user: User | null = null; + + try { + user = await client.users.fetch(idToUse); + } catch (e) { + return interaction.editReply('An error has occurred. Are you using the right format? You can provide a user ID (ex `324007235137044482`) or a user mention (you must have text previews enabled, Settings -> Chat -> Text Box).'); + } if (!user) return interaction.editReply("Couldn't find user."); diff --git a/src/commands/notes.ts b/src/commands/notes.ts index 4596696..0881cc4 100644 --- a/src/commands/notes.ts +++ b/src/commands/notes.ts @@ -1,4 +1,4 @@ -import { ApplicationCommandOptionType, ApplicationIntegrationType, AutocompleteInteraction, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, MessageMentions, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js'; +import { ApplicationCommandOptionType, ApplicationIntegrationType, AutocompleteInteraction, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, MessageMentions, PermissionFlagsBits, SlashCommandBuilder, User } from 'discord.js'; import { Database } from '../shared/Database'; import { channelIsInStaffCategory, deferInteraction, logCustomEvent } from '../utils'; import { getNoteMessage } from '../utils/note-utils'; @@ -95,7 +95,13 @@ export default { await deferInteraction(interaction); - const user = await client.users.fetch(idToUse); + let user: User | null = null; + + try { + user = await client.users.fetch(idToUse); + } catch (e) { + return interaction.editReply('An error has occurred. Are you using the right format? You can provide a user ID (ex `324007235137044482`) or a user mention (you must have text previews enabled, Settings -> Chat -> Text Box).'); + } if (!user) return interaction.editReply('User not found');