feat: lenient psa

This commit is contained in:
TrèsAbhi committed 2024-04-10 16:29:12 -05:00
1 parent f02db6ef0b
commit ab26b346e6
2 files changed
+20 -13

No files matched your search

+6 -5
View File
@@ -6,16 +6,17 @@ export type PSAData = {
}[];
commands?: string[];
} & (
| {
type?: 'embed';
title: string;
description: string;
image?: string;
}
| {
type: 'image';
image: string;
title?: string;
}
| {
type: 'embed';
title: string;
description: string;
}
);
export interface PSA {
@@ -63,10 +63,14 @@ export default async function handleChatInputCommand(
(psa.data.commands === undefined ||
psa.data.commands.includes(interaction.commandName))
) {
if (psa.data.type === 'embed') {
if (psa.data.type === undefined || psa.data.type === 'embed') {
if (!reply.embeds) reply.embeds = [];
reply.embeds.push(embedWarning(psa.data.title, psa.data.description));
} else {
const embed = embedWarning(psa.data.title, psa.data.description);
if (psa.data.image) embed.setImage(psa.data.image);
reply.embeds.push(embed);
} else if (psa.data.type === 'image') {
if (!reply.files) reply.files = [];
reply.files.push(new AttachmentBuilder(psa.data.image));
reply.content = reply.content ?? psa.data.title;
@@ -101,12 +105,14 @@ export default async function handleChatInputCommand(
ephemeral: true,
};
if (psa.data.type === 'embed') {
if (psa.data.type === undefined || psa.data.type === 'embed') {
if (!followUp.embeds) followUp.embeds = [];
followUp.embeds.push(
embedWarning(psa.data.title, psa.data.description),
);
} else {
const embed = embedWarning(psa.data.title, psa.data.description);
if (psa.data.image) embed.setImage(psa.data.image);
followUp.embeds.push(embed);
} else if (psa.data.type === 'image') {
if (!followUp.files) followUp.files = [];
followUp.files.push(new AttachmentBuilder(psa.data.image));
followUp.content = followUp.content ?? psa.data.title;