UNPKG

discord-webhook-ts

Version:

Client & Type definitions for the Discord Webhooks API. 📘

52 lines (51 loc) • 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const axios_1 = __importDefault(require("axios")); class DiscordWebhook { /** * Discord Webhook constructor */ constructor(webhookUrl) { this.client = axios_1.default.create({ baseURL: webhookUrl, }); } /** * Execute the current webhook. */ execute(options) { return this.client.request({ method: 'POST', data: options, }); } /** * Modify the current webhook. */ modify(options) { return this.client.request({ method: 'PATCH', data: options, }); } /** * Get the current webhook. */ get() { return this.client.request({ method: 'GET', }); } /** * Check whether or not the current webhook is valid. */ isValid() { return this.get() .then(() => true) .catch(() => false); } } exports.default = DiscordWebhook;