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
if (quoted_post?.attachments.size) {
if (quoted_post?.attachments.size !== 0) {
if (quoted_post?.attachments.size === 1 && isImage(
quoted_post.attachments.first()?.name as string
)) {
// Only contains one image
embed.setImage(quoted_post.attachments.first()?.url as string);
} else {
// Contains more than one image or other files
// Contains more than one image and/or other files
let files = '';
quoted_post?.attachments.forEach(attachment => {
files += `[${attachment.name}](${attachment.url}), `;
});
quoted_post?.attachments.forEach(file => files +=
`[${file.name}](${file.url}), `
);
embed.addFields({
name: 'Fichiers joints',
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 ?? '');
// Footer
@ -130,7 +130,7 @@ export default async (message: Message, client: Client) => {
author += ' & Citateur';
} else {
footer += `\nCité par ${userWithNickname(
message.guild?.members.cache.get(message.author.id) as GuildMember
message.member as GuildMember
) ?? '?'} le ${showDate(
client.config.default_lang,
loc,
@ -143,13 +143,27 @@ export default async (message: Message, client: Client) => {
iconURL: message.author.avatarURL() ?? undefined,
});
// Info about the post
// Location and author of the post
embed.addField(author, `${quoted_post?.author}`, true);
embed.addField(
'Message', `${quoted_post?.channel} - [Lien Message](${quoted_post?.url})`,
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] });
} else {
return message.reply({
embeds: [embed],
allowedMentions: {
repliedUser: false,
},
});
}
});
};