diff --git a/src/events/message/messageCreate.ts b/src/events/message/messageCreate.ts index 4d82dbf..23d9954 100644 --- a/src/events/message/messageCreate.ts +++ b/src/events/message/messageCreate.ts @@ -81,7 +81,7 @@ export default async (message: Message, client: Client) => { const loc = getLocale(client, client.config.default_lang); - // Remove duplicates + // Remove duplicates then map the quoted posts [...new Set(messages)].map(quoted_post => { const embed = new MessageEmbed() .setColor('#2f3136') @@ -104,7 +104,10 @@ export default async (message: Message, client: Client) => { `[${file.name}](${file.url}), ` ); embed.addFields({ + // TODO: Don't pluralize when there is only one file. name: 'Fichiers joints', + // TODO: Check if don't exceed char limit, if yes, split + // files into multiples field. value: `${files.slice(0, -2)}.`, }); } @@ -145,13 +148,14 @@ export default async (message: Message, client: Client) => { iconURL: message.author.avatarURL() ?? undefined, }); - // Location and author of the post + // Location/author of the quoted post embed.addField(author, `${quoted_post?.author}`, true); embed.addField( 'Message', `${quoted_post?.channel} - [Lien Message](${quoted_post?.url})`, true ); + // Delete source message if no content when removing links if ( !message.content.replace(new RegExp(regex, 'g'), '').trim() && messages.length === urls.length &&