UNPKG

homebridge-http-sensors-switches

Version:

This plugin communicates with your devices over HTTP or MQTT. Currently it supports Light Bulb, Switches, Outlets, Fan, Garage Door, Shades / Blinds, Temperature/Humidity, Motion, Contact and Occupancy sensor, Air Quality, Smoke, Carbon Dioxide and Light

49 lines 1.57 kB
// discordWebHooks.ts import axios from 'axios'; export class discordWebHooks { discordWebhook; discordUsername; discordAvatar; discordMessage; PostData; constructor(discordWebhook, discordUsername, discordAvatar, discordMessage) { this.discordWebhook = discordWebhook; this.discordUsername = discordUsername; this.discordAvatar = discordAvatar; this.discordMessage = discordMessage; this.PostData = JSON.stringify({ username: this.discordUsername, avatar_url: this.discordAvatar, content: this.discordMessage, allowed_mentions: { parse: ['users', 'roles'], }, }); } async discordSimpleSend() { try { await axios({ url: this.discordWebhook, data: this.PostData, method: 'post', timeout: 8000, headers: { 'Content-Type': 'application/json', }, }); return new Promise((resolve) => { setTimeout(() => resolve('Success sending Discord Message'), 1000); }); } catch (e) { const error = e; if (axios.isAxiosError(error)) { return (String(error.message)); } return new Promise((resolve) => { setTimeout(() => resolve('Error sending Discord message'), 1000); }); } } } //# sourceMappingURL=discordWebHooks.js.map