Skip to content

Commit

Permalink
chore(forwardReport): use consistent message style
Browse files Browse the repository at this point in the history
  • Loading branch information
JPBM135 committed Feb 16, 2023
1 parent c6bbfd4 commit 57f8c56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions apps/yuudachi/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@
"updated_at": "**Updated at:** {{- updated_at}}",
"footer": "Hint: To resolve a report: Change the status forum label, reference it in a case, set the reference for an existing case with /reference, or set the status via /reports status",
"forward": {
"message": "**Message report forwarded**\n • Author: {{- author}}\n • Reason: {{- reason}}",
"user": "**Attachment forwarded**\n • Author: {{- author}}\n • Reason: {{- reason}}",
"message": "Message report forwarded",
"user": "Attachment forwarded",
"errors": {
"generic": "There was an error forwarding the report.",
"no_thread": "There was an error forwarding the report the associated thread could not be found."
Expand Down
27 changes: 20 additions & 7 deletions apps/yuudachi/src/functions/logging/forwardReport.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createMessageActionRow } from "@yuudachi/framework";
import type { APIEmbed, Attachment, AttachmentPayload, Guild, User } from "discord.js";
import { inlineCode, userMention, Message } from "discord.js";
import { codeBlock, Message } from "discord.js";
import i18next from "i18next";
import { Color } from "../../Constants.js";
import { createMessageLinkButton } from "../../util/createMessageLinkButton.js";
Expand Down Expand Up @@ -35,8 +35,26 @@ export async function forwardReport(
throw new Error(i18next.t("log.report_log.forward.errors.no_thread", { lng: locale }));
}

const embeds: APIEmbed[] = [];
const isMessage = payload instanceof Message;
const embeds: APIEmbed[] = [
{
author: {
name: `${author.tag} (${author.id})`,
icon_url: author.displayAvatarURL(),
},
description: i18next.t("log.report_log.reason", {
reason: codeBlock(reason),
lng: locale,
}),
footer: {
text: i18next.t(`log.report_log.forward.${isMessage ? "message" : "user"}`, {
lng: locale,
}),
},
timestamp: new Date().toISOString(),
color: Color.DiscordPrimary,
},
];

if (isMessage) {
await updateReport({
Expand All @@ -56,11 +74,6 @@ export async function forwardReport(
}

await thread.send({
content: i18next.t(`log.report_log.forward.${isMessage ? "message" : "user"}`, {
author: `${userMention(author.id)} - \`${author.tag}\` (${author.id})`,
reason: inlineCode(reason),
lng: locale,
}),
embeds,
components: isMessage ? [createMessageActionRow([createMessageLinkButton(payload as Message<true>, locale)])] : [],
allowedMentions: {
Expand Down

0 comments on commit 57f8c56

Please sign in to comment.