Files
hikari/server/src/modules/getSanctionComponents.ts
T

57 lines
1.4 KiB
TypeScript

/**
* @copyright NHCarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
interface Payload {
number: number;
platform: string;
reason: string;
type: string;
username: string;
uuid: string;
}
/**
* Formats a sanction payload from the API into Discord ComponentsV2.
* @param payload -- The sanction payload from the API.
* @returns A component JSON array.
*/
export const getSanctionComponents
= (payload: Payload): Array<Record<string, unknown>> => {
const { number, platform, reason, type, username, uuid } = payload;
return [
{
// eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API standard.
accent_color: 15_418_782,
components: [
{
content: `# Case #${number.toString()}: ${type.toUpperCase()}`,
type: 10,
},
{
divider: true,
spacing: 1,
type: 14,
},
{
content: `## Reason:\n\n${reason}`,
type: 10,
},
{
divider: true,
spacing: 1,
type: 14,
},
{
content: `## Metadata\n\n- Platform: ${platform}\n- UUID: ${uuid}\n- Username: ${username}`,
type: 10,
},
],
spoiler: false,
type: 17,
},
];
};