You've already forked NitroSniper
mirror of
https://github.com/neoarz/NitroSniper.git
synced 2026-05-11 13:15:37 +02:00
feat: webhook support
This commit is contained in:
47
settings.tsx
Normal file
47
settings.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { OptionType } from "@utils/types";
|
||||
import { Button, showToast, Toasts } from "@webpack/common";
|
||||
|
||||
import { sendTestWebhook } from "./webhook";
|
||||
|
||||
function TestWebhookButton() {
|
||||
const { webhookUrl } = settings.use(["webhookUrl"]);
|
||||
const disabled = webhookUrl.trim().length === 0;
|
||||
|
||||
return (
|
||||
<Button
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
void sendTestWebhook(webhookUrl)
|
||||
.then(() => {
|
||||
showToast("Test webhook sent successfully.", Toasts.Type.SUCCESS);
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
showToast(error.message, Toasts.Type.FAILURE);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Send Test Webhook
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export const settings = definePluginSettings({
|
||||
ignoreOwnGiftLinks: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Do not redeem Nitro gift links from messages sent by you.",
|
||||
default: false,
|
||||
restartNeeded: false
|
||||
},
|
||||
webhookUrl: {
|
||||
type: OptionType.STRING,
|
||||
description: "Discord webhook URL to notify after each redeem attempt. Leave empty to disable.",
|
||||
default: "",
|
||||
restartNeeded: false
|
||||
},
|
||||
testWebhook: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "Send a test message to the configured webhook.",
|
||||
component: TestWebhookButton
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user