feat: quote #42

Merged
Anri merged 16 commits from feat/citation into main 2022-07-27 13:00:24 +02:00
Showing only changes of commit 65559753b7 - Show all commits

View file

@ -89,18 +89,18 @@ export default async (message: Message, client: Client) => {
}); });
// Handle attachments // Handle attachments
if (quoted_post?.attachments.size) { if (quoted_post?.attachments.size !== 0) {
if (quoted_post?.attachments.size === 1 && isImage( if (quoted_post?.attachments.size === 1 && isImage(
quoted_post.attachments.first()?.name as string quoted_post.attachments.first()?.name as string
)) { )) {
// Only contains one image // Only contains one image
embed.setImage(quoted_post.attachments.first()?.url as string); embed.setImage(quoted_post.attachments.first()?.url as string);
} else { } else {
// Contains more than one image or other files // Contains more than one image and/or other files
let files = ''; let files = '';
quoted_post?.attachments.forEach(attachment => { quoted_post?.attachments.forEach(file => files +=
files += `[${attachment.name}](${attachment.url}), `; `[${file.name}](${file.url}), `
}); );
embed.addFields({ embed.addFields({
name: 'Fichiers joints', name: 'Fichiers joints',
value: `${files.slice(0, -2)}.`, value: `${files.slice(0, -2)}.`,
@ -108,7 +108,7 @@ export default async (message: Message, client: Client) => {
} }
} }
// Description // Description as post content
embed.setDescription(quoted_post?.content ?? ''); embed.setDescription(quoted_post?.content ?? '');
// Footer // Footer
@ -130,7 +130,7 @@ export default async (message: Message, client: Client) => {
author += ' & Citateur'; author += ' & Citateur';
} else { } else {
footer += `\nCité par ${userWithNickname( footer += `\nCité par ${userWithNickname(
message.guild?.members.cache.get(message.author.id) as GuildMember message.member as GuildMember
) ?? '?'} le ${showDate( ) ?? '?'} le ${showDate(
client.config.default_lang, client.config.default_lang,
loc, loc,
@ -143,13 +143,27 @@ export default async (message: Message, client: Client) => {
iconURL: message.author.avatarURL() ?? undefined, iconURL: message.author.avatarURL() ?? undefined,
}); });
// Info about the post // Location and author of the post
embed.addField(author, `${quoted_post?.author}`, true); embed.addField(author, `${quoted_post?.author}`, true);
embed.addField( embed.addField(
'Message', `${quoted_post?.channel} - [Lien Message](${quoted_post?.url})`, 'Message', `${quoted_post?.channel} - [Lien Message](${quoted_post?.url})`,
true true
); );
if (
!message.content.replace(new RegExp(regex, 'g'), '').trim() &&
messages.length === urls.length &&
!message.mentions.repliedUser
) {
message.delete();
return message.channel.send({ embeds: [embed] }); return message.channel.send({ embeds: [embed] });
} else {
return message.reply({
embeds: [embed],
allowedMentions: {
repliedUser: false,
},
});
}
}); });
}; };