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) => {
|
client.on('messageCreate', async (e) => {
|
||||||
if (e.channel.partial) await e.channel.fetch();
|
try {
|
||||||
if (e.author.partial) await e.author.fetch();
|
if (e.channel.partial) await e.channel.fetch();
|
||||||
|
if (e.author.partial) await e.author.fetch();
|
||||||
|
|
||||||
if (!e.content) return;
|
if (!e.content) return;
|
||||||
if (!e.channel.isTextBased()) 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)) {
|
if (e.cleanContent.match(BuildConfig.ETA_REGEX)) {
|
||||||
await e.reply(
|
await e.reply(
|
||||||
`${random(BuildConfig.ETA_MESSAGES)} <:pofat:1031701005559144458>`
|
`${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) => {
|
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,26 +129,32 @@ 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) => {
|
||||||
if (reaction.partial) {
|
try {
|
||||||
try {
|
if (reaction.partial) {
|
||||||
await reaction.fetch();
|
try {
|
||||||
} catch (error) {
|
await reaction.fetch();
|
||||||
console.error('Something went wrong when fetching the message:', error);
|
} catch (error) {
|
||||||
return;
|
console.error('Something went wrong when fetching the message:', error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
reaction.message.interaction &&
|
reaction.message.interaction &&
|
||||||
reaction.message.interaction?.type === InteractionType.ApplicationCommand &&
|
reaction.message.interaction?.type === InteractionType.ApplicationCommand &&
|
||||||
reaction.message.interaction?.user === user &&
|
reaction.message.interaction?.user === user &&
|
||||||
reaction.emoji.name === '❌'
|
reaction.emoji.name === '❌'
|
||||||
) {
|
) {
|
||||||
await reaction.message.delete();
|
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
|
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 {
|
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 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