diff --git a/src/commands/quoteCommand.ts b/src/commands/quoteCommand.ts index c875576f..15d64167 100644 --- a/src/commands/quoteCommand.ts +++ b/src/commands/quoteCommand.ts @@ -24,7 +24,7 @@ import Command from "./command"; export class QuoteCommand extends Command { private readonly messageLinkRegex: RegExp = - /https:\/\/(?:(?:ptb|canary)\.)?discord\.com\/channels\/(?[0-9]{17,18})\/(?[0-9]{17,18})\/(?[0-9]{17,18})/; + /https:\/\/(?:(?:ptb|canary)\.)?discord\.com\/channels\/(?\d*)\/(?\d*)\/(?\d*)$/; override data() { if (!QUOTE_ROLE_ID) return []; @@ -100,11 +100,16 @@ export class QuoteCommand extends Command { }); const commandIssuerNick = await this.getAuthorNick(guild, interaction.user); - const pullRequestNumber = await githubAPI.openFortunesPullRequest( - fortunes, - commandIssuerNick, - nickname - ); + let pullRequestNumber; + try { + pullRequestNumber = await githubAPI.openFortunesPullRequest( + fortunes, + commandIssuerNick, + nickname + ); + } catch (e) { + console.trace(e); + } if (pullRequestNumber == undefined) { const sadcaret = await getSadCaret(interaction); @@ -159,13 +164,10 @@ export class QuoteCommand extends Command { }; } - const originalMessage = await interaction.channel?.messages.fetch(interaction.commandId); - if (!originalMessage) return; - // Option 3b: The quote's message ID was given try { - const message = await originalMessage.channel.messages.fetch(argument); - if (message.guild == null) return; + const message = await interaction.channel?.messages.fetch(argument); + if (message?.guild == null) return; return { guildId: message.guild.id, channelId: message.channel.id,