Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuoteCommand: Getting it working again #1033

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/commands/quoteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Command from "./command";

export class QuoteCommand extends Command {
private readonly messageLinkRegex: RegExp =
/https:\/\/(?:(?:ptb|canary)\.)?discord\.com\/channels\/(?<guild>[0-9]{17,18})\/(?<channel>[0-9]{17,18})\/(?<message>[0-9]{17,18})/;
/https:\/\/(?:(?:ptb|canary)\.)?discord\.com\/channels\/(?<guild>\d*)\/(?<channel>\d*)\/(?<message>\d*)$/;

override data() {
if (!QUOTE_ROLE_ID) return [];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
Loading