Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(forwardReport): use consistent message style #1175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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