Compare commits
2 commits
facf0cd88e
...
3e85f7cd5c
Author | SHA1 | Date | |
---|---|---|---|
3e85f7cd5c | |||
4667b668d5 |
2 changed files with 89 additions and 82 deletions
|
@ -98,21 +98,23 @@ export default async (message: Message, client: Client) => {
|
||||||
const loc = getLocale(client, client.config.default_lang);
|
const loc = getLocale(client, client.config.default_lang);
|
||||||
|
|
||||||
// Remove duplicates then map the quoted posts
|
// Remove duplicates then map the quoted posts
|
||||||
[...new Set(messages)].map((quoted_post) => {
|
[...new Set(messages)]
|
||||||
|
.filter((p) => p !== undefined)
|
||||||
|
.map((quoted_post) => {
|
||||||
const embed = new EmbedBuilder().setColor("#2f3136").setAuthor({
|
const embed = new EmbedBuilder().setColor("#2f3136").setAuthor({
|
||||||
name: "Citation",
|
name: "Citation",
|
||||||
iconURL: quoted_post?.author.displayAvatarURL(),
|
iconURL: quoted_post.author.displayAvatarURL(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle attachments
|
// Handle attachments
|
||||||
if (quoted_post?.attachments.size !== 0) {
|
if (quoted_post.attachments.size !== 0) {
|
||||||
if (quoted_post?.attachments.size === 1 && isImage(quoted_post.attachments.first()!.name)) {
|
if (quoted_post.attachments.size === 1 && isImage(quoted_post.attachments.first()!.name)) {
|
||||||
// Only contains one image
|
// Only contains one image
|
||||||
embed.setImage(quoted_post.attachments.first()!.url);
|
embed.setImage(quoted_post.attachments.first()!.url);
|
||||||
} else {
|
} else {
|
||||||
// Contains more than one image and/or other files
|
// Contains more than one image and/or other files
|
||||||
let files = "";
|
let files = "";
|
||||||
quoted_post?.attachments.forEach((file) => (files += `[${file.name}](${file.url}), `));
|
quoted_post.attachments.forEach((file) => (files += `[${file.name}](${file.url}), `));
|
||||||
embed.addFields({
|
embed.addFields({
|
||||||
// TODO: Don't pluralize when there is only one file.
|
// TODO: Don't pluralize when there is only one file.
|
||||||
// TODO: Locales
|
// TODO: Locales
|
||||||
|
@ -125,19 +127,19 @@ export default async (message: Message, client: Client) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description as post content
|
// Description as post content
|
||||||
if (quoted_post?.content) {
|
if (quoted_post.content) {
|
||||||
// Only if content exists and length > 0
|
// Only if content exists and length > 0
|
||||||
embed.setDescription(quoted_post?.content);
|
embed.setDescription(quoted_post.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
let footer = `Posté le ${showDate(loc, quoted_post!.createdAt)}`;
|
let footer = `Posté le ${showDate(loc, quoted_post.createdAt)}`;
|
||||||
if (quoted_post?.editedAt) {
|
if (quoted_post.editedAt) {
|
||||||
footer += ` et modifié le ${showDate(loc, quoted_post.editedAt)}`;
|
footer += ` et modifié le ${showDate(loc, quoted_post.editedAt)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let author = "Auteur";
|
let author = "Auteur";
|
||||||
if (message.author === quoted_post?.author) {
|
if (message.author === quoted_post.author) {
|
||||||
author += " & Citateur";
|
author += " & Citateur";
|
||||||
} else {
|
} else {
|
||||||
footer += `\nCité par ${userWithNickname(message.member!) ?? "?"} le ${showDate(
|
footer += `\nCité par ${userWithNickname(message.member!) ?? "?"} le ${showDate(
|
||||||
|
@ -155,12 +157,12 @@ export default async (message: Message, client: Client) => {
|
||||||
embed.addFields(
|
embed.addFields(
|
||||||
{
|
{
|
||||||
name: author,
|
name: author,
|
||||||
value: `${quoted_post?.author}`,
|
value: `${quoted_post.author}`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Message",
|
name: "Message",
|
||||||
value: `${quoted_post?.channel} - [Lien Message](${quoted_post?.url})`,
|
value: `${quoted_post.channel} - [Lien Message](${quoted_post.url})`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,8 +6,13 @@
|
||||||
* @returns String
|
* @returns String
|
||||||
*/
|
*/
|
||||||
export const showDate = (locale: Map<string, unknown>, date: Date) => {
|
export const showDate = (locale: Map<string, unknown>, date: Date) => {
|
||||||
const timezoned = new Date(date.getTime());
|
const timezoned = new Date(date.getTime() + date.getTimezoneOffset() * 60000);
|
||||||
return `${timezoned.toDateString()} ${locale.get("u_time_at")} ${timezoned.toTimeString().split(" ")[0]}`;
|
|
||||||
|
console.log(date.getTimezoneOffset());
|
||||||
|
|
||||||
|
return `${timezoned.toDateString()} ${locale.get("u_time_at")} ${
|
||||||
|
timezoned.toTimeString().split(" ")[0]
|
||||||
|
}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TimeSecond {
|
enum TimeSecond {
|
||||||
|
|
Loading…
Reference in a new issue