error handling

This commit is contained in:
nin0 2025-05-02 07:35:24 -04:00
parent df291c7d00
commit 7d13506b41
Signed by: nin0
SSH key fingerprint: SHA256:NOoDnFVvZNFvqfXCIhzr6oCTDImZAbTTuyAysZ8Ufk8

View file

@ -4,7 +4,9 @@ const {
ApplicationCommandTypes,
InteractionTypes,
ApplicationIntegrationTypes,
InteractionContextTypes
InteractionContextTypes,
MessageFlags,
ComponentTypes
} = require("oceanic.js");
const client = new Client({
@ -38,6 +40,12 @@ client.on("ready", () => {
description: "...",
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false
},
{
name: "cv2",
description: "...",
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false
}
]
}
@ -58,6 +66,18 @@ client.on("interactionCreate", async (interaction) => {
if (interaction.data.type === ApplicationCommandTypes.CHAT_INPUT) {
const content = interaction.data.options.getString("content", true);
const raw = interaction.data.options.getBoolean("raw");
const cv2Text = interaction.data.options.getBoolean("cv2");
if (cv2Text)
interaction.createFollowup({
flags: MessageFlags.IS_UIKIT_COMPONENTS,
components: [
{
type: ComponentTypes.TEXT,
content
}
]
});
interaction.createFollowup(
raw
@ -70,4 +90,10 @@ client.on("interactionCreate", async (interaction) => {
}
});
process.on("uncaughtException", (e) => {
client.rest.channels.createMessage("1367826538665476236", {
content: "```\n" + e.stack || e.message + "\n```"
});
});
client.connect();