Oops :pofat:
This commit is contained in:
parent
cd8f8e4f9b
commit
2e4e81d7a2
2 changed files with 57 additions and 46 deletions
72
src/index.ts
72
src/index.ts
|
@ -77,30 +77,36 @@ client.once('ready', async () => {
|
|||
});
|
||||
|
||||
client.on('messageCreate', async (e) => {
|
||||
if (e.channel.partial) await e.channel.fetch();
|
||||
if (e.author.partial) await e.author.fetch();
|
||||
try {
|
||||
if (e.channel.partial) await e.channel.fetch();
|
||||
if (e.author.partial) await e.author.fetch();
|
||||
|
||||
if (!e.content) return;
|
||||
if (!e.channel.isTextBased()) return;
|
||||
if (!e.content) return;
|
||||
if (!e.channel.isTextBased()) return;
|
||||
|
||||
if (e.author === client.user) return;
|
||||
if (e.author === client.user) return;
|
||||
|
||||
if (e.cleanContent.match(BuildConfig.ETA_REGEX)) {
|
||||
await e.reply(
|
||||
`${random(BuildConfig.ETA_MESSAGES)} <:pofat:1031701005559144458>`
|
||||
);
|
||||
if (e.cleanContent.match(BuildConfig.ETA_REGEX)) {
|
||||
await e.reply(
|
||||
`${random(BuildConfig.ETA_MESSAGES)} <:pofat:1031701005559144458>`
|
||||
);
|
||||
}
|
||||
const log = await parseLog(e.content);
|
||||
if (log != null) {
|
||||
e.reply({ embeds: [log] });
|
||||
return;
|
||||
}
|
||||
await expandDiscordLink(e);
|
||||
} catch (error) {
|
||||
console.error('Unhandled exception on messageCreate', error);
|
||||
}
|
||||
const log = await parseLog(e.content);
|
||||
if (log != null) {
|
||||
e.reply({ embeds: [log] });
|
||||
return;
|
||||
}
|
||||
await expandDiscordLink(e);
|
||||
});
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async (interaction) => {
|
||||
if (interaction.isChatInputCommand()) {
|
||||
try {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const { commandName } = interaction;
|
||||
|
||||
if (commandName === 'ping') {
|
||||
|
@ -123,26 +129,32 @@ 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) => {
|
||||
if (reaction.partial) {
|
||||
try {
|
||||
await reaction.fetch();
|
||||
} catch (error) {
|
||||
console.error('Something went wrong when fetching the message:', error);
|
||||
return;
|
||||
try {
|
||||
if (reaction.partial) {
|
||||
try {
|
||||
await reaction.fetch();
|
||||
} catch (error) {
|
||||
console.error('Something went wrong when fetching the message:', error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
reaction.message.interaction &&
|
||||
reaction.message.interaction?.type === InteractionType.ApplicationCommand &&
|
||||
reaction.message.interaction?.user === user &&
|
||||
reaction.emoji.name === '❌'
|
||||
) {
|
||||
await reaction.message.delete();
|
||||
if (
|
||||
reaction.message.interaction &&
|
||||
reaction.message.interaction?.type === InteractionType.ApplicationCommand &&
|
||||
reaction.message.interaction?.user === user &&
|
||||
reaction.emoji.name === '❌'
|
||||
) {
|
||||
await reaction.message.delete();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Unhandled exception on messageReactionAdd', error);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -32,21 +32,21 @@ 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
|
||||
|
||||
const channel = await message.guild?.channels.fetch(r.groups.channelId);
|
||||
|
||||
if (!channel || !channel.isTextBased()) continue;
|
||||
|
||||
if (channel instanceof ThreadChannel) {
|
||||
if (
|
||||
!channel.parent?.members?.some((user) => user.id == message.author.id)
|
||||
)
|
||||
continue; // do not reveal a message to a user who can't see it
|
||||
} else {
|
||||
if (!channel.members?.some((user) => user.id == message.author.id))
|
||||
continue; // do not reveal a message to a user who can't see it
|
||||
}
|
||||
|
||||
try {
|
||||
const channel = await message.guild?.channels.fetch(r.groups.channelId);
|
||||
|
||||
if (!channel || !channel.isTextBased()) continue;
|
||||
|
||||
if (channel instanceof ThreadChannel) {
|
||||
if (
|
||||
!channel.parent?.members?.some((user) => user.id == message.author.id)
|
||||
)
|
||||
continue; // do not reveal a message to a user who can't see it
|
||||
} else {
|
||||
if (!channel.members?.some((user) => user.id == message.author.id))
|
||||
continue; // do not reveal a message to a user who can't see it
|
||||
}
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue