Oops :pofat:

This commit is contained in:
TheKodeToad 2023-06-04 12:39:14 +01:00
parent cd8f8e4f9b
commit 2e4e81d7a2
2 changed files with 57 additions and 46 deletions

View file

@ -77,6 +77,7 @@ client.once('ready', async () => {
});
client.on('messageCreate', async (e) => {
try {
if (e.channel.partial) await e.channel.fetch();
if (e.author.partial) await e.author.fetch();
@ -96,11 +97,16 @@ client.once('ready', async () => {
return;
}
await expandDiscordLink(e);
} catch (error) {
console.error('Unhandled exception on messageCreate', error);
}
});
});
client.on('interactionCreate', async (interaction) => {
if (interaction.isChatInputCommand()) {
try {
if (!interaction.isChatInputCommand()) return;
const { commandName } = interaction;
if (commandName === 'ping') {
@ -123,10 +129,13 @@ client.on('interactionCreate', async (interaction) => {
} else if (commandName === 'rory') {
await roryCommand(interaction);
}
} catch (error) {
console.error('Unhandled exception on interactionCreate', error);
}
});
client.on('messageReactionAdd', async (reaction, user) => {
try {
if (reaction.partial) {
try {
await reaction.fetch();
@ -144,6 +153,9 @@ client.on('messageReactionAdd', async (reaction, user) => {
) {
await reaction.message.delete();
}
} catch (error) {
console.error('Unhandled exception on messageReactionAdd', error);
}
});
reuploadCommands()

View file

@ -32,6 +32,7 @@ export async function expandDiscordLink(message: Message): Promise<void> {
if (r.groups == undefined || r.groups.serverId != message.guildId) continue; // do not let the bot leak messages from one server to another
try {
const channel = await message.guild?.channels.fetch(r.groups.channelId);
if (!channel || !channel.isTextBased()) continue;
@ -46,7 +47,6 @@ export async function expandDiscordLink(message: Message): Promise<void> {
continue; // do not reveal a message to a user who can't see it
}
try {
const originalMessage = await channel.messages.fetch(r.groups.messageId);
const embed = new EmbedBuilder()
@ -78,8 +78,7 @@ export async function expandDiscordLink(message: Message): Promise<void> {
}
resultEmbeds.push(embed);
} catch (e) {
console.error(e);
} catch (ignored) {
}
}