Skip to content
Draft
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
9 changes: 9 additions & 0 deletions src/listeners/client/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class MessageCreateListener extends Listener {
yield await this._quoteLinkedMessage(message);
yield await this._antispamSnippetsChannel(message);
yield await this._checkCreationsChannelRules(message);
yield await this._checkMediaDiscordapp(message);
return false;
}

Expand Down Expand Up @@ -92,6 +93,14 @@ export default class MessageCreateListener extends Listener {
return false;
}

private async _checkMediaDiscordapp(message: GuildMessage): Promise<boolean> {
if (!/media\.discordapp\.net+/.test(message.content))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!/media\.discordapp\.net+/.test(message.content))
if (!message.content.includes('media.discordapp.net'))

return false;
await message.channel.send(message.content.replace(/media\.discordapp\.net+/, 'cdn.discordapp.com'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await message.channel.send(message.content.replace(/media\.discordapp\.net+/, 'cdn.discordapp.com'));
await message.channel.send(message.content.replace(/media\.discordapp\.net/, 'cdn.discordapp.com'));

Le + en regex veut dire "ce qu'il y a avant (ici un "t"), 1 ou plusieurs fois" 😄 Donc la ca matchait ---.net mais aussi ---.netttt :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylé stylé, je le fais quand j'suis chez oim.

await message.delete();
return false;
}

private async _handleSuggestion(message: GuildMessage): Promise<boolean> {
// Send embed and add reactions in the Suggestion channel.
if (message.channel.id === settings.channels.suggestions) {
Expand Down