Merge pull request #179 from TheKodeToad/crashfix
This commit is contained in:
commit
71b68c4a78
2 changed files with 57 additions and 46 deletions
14
src/index.ts
14
src/index.ts
|
@ -77,6 +77,7 @@ client.once('ready', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageCreate', async (e) => {
|
client.on('messageCreate', async (e) => {
|
||||||
|
try {
|
||||||
if (e.channel.partial) await e.channel.fetch();
|
if (e.channel.partial) await e.channel.fetch();
|
||||||
if (e.author.partial) await e.author.fetch();
|
if (e.author.partial) await e.author.fetch();
|
||||||
|
|
||||||
|
@ -96,11 +97,16 @@ client.once('ready', async () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await expandDiscordLink(e);
|
await expandDiscordLink(e);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Unhandled exception on messageCreate', error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('interactionCreate', async (interaction) => {
|
client.on('interactionCreate', async (interaction) => {
|
||||||
if (interaction.isChatInputCommand()) {
|
try {
|
||||||
|
if (!interaction.isChatInputCommand()) return;
|
||||||
|
|
||||||
const { commandName } = interaction;
|
const { commandName } = interaction;
|
||||||
|
|
||||||
if (commandName === 'ping') {
|
if (commandName === 'ping') {
|
||||||
|
@ -123,10 +129,13 @@ client.on('interactionCreate', async (interaction) => {
|
||||||
} else if (commandName === 'rory') {
|
} else if (commandName === 'rory') {
|
||||||
await roryCommand(interaction);
|
await roryCommand(interaction);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Unhandled exception on interactionCreate', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageReactionAdd', async (reaction, user) => {
|
client.on('messageReactionAdd', async (reaction, user) => {
|
||||||
|
try {
|
||||||
if (reaction.partial) {
|
if (reaction.partial) {
|
||||||
try {
|
try {
|
||||||
await reaction.fetch();
|
await reaction.fetch();
|
||||||
|
@ -144,6 +153,9 @@ client.on('messageReactionAdd', async (reaction, user) => {
|
||||||
) {
|
) {
|
||||||
await reaction.message.delete();
|
await reaction.message.delete();
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Unhandled exception on messageReactionAdd', error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
reuploadCommands()
|
reuploadCommands()
|
||||||
|
|
|
@ -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
|
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);
|
const channel = await message.guild?.channels.fetch(r.groups.channelId);
|
||||||
|
|
||||||
if (!channel || !channel.isTextBased()) continue;
|
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
|
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 originalMessage = await channel.messages.fetch(r.groups.messageId);
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
|
@ -78,8 +78,7 @@ export async function expandDiscordLink(message: Message): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
resultEmbeds.push(embed);
|
resultEmbeds.push(embed);
|
||||||
} catch (e) {
|
} catch (ignored) {
|
||||||
console.error(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue