Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/maybeanerd/MagiBot. MagiBot - the community building discord bot that adds joinsounds to your voice discord.gg/2Evcf4T
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273import Discord from 'discord.js';import { doNothingOnError } from './helperFunctions';
const { WEBHOOK_ID_EX, WEBHOOK_TOKEN_EX, WEBHOOK_ID_JOIN, WEBHOOK_TOKEN_JOIN, WEBHOOK_ID_BUG, WEBHOOK_TOKEN_BUG, WEBHOOK_ID_STARTUP, WEBHOOK_TOKEN_STARTUP,} = process.env;if ( !( WEBHOOK_ID_EX && WEBHOOK_TOKEN_EX && WEBHOOK_ID_JOIN && WEBHOOK_TOKEN_JOIN && WEBHOOK_ID_BUG && WEBHOOK_TOKEN_BUG && WEBHOOK_ID_STARTUP && WEBHOOK_TOKEN_STARTUP )) { throw new Error('Discord Webhook information is missing.');}
const exceptionsWebhook = new Discord.WebhookClient({ id: WEBHOOK_ID_EX, token: WEBHOOK_TOKEN_EX,});const joinsWebhook = new Discord.WebhookClient({ id: WEBHOOK_ID_JOIN, token: WEBHOOK_TOKEN_JOIN,});const bugreportWebhook = new Discord.WebhookClient({ id: WEBHOOK_ID_BUG, token: WEBHOOK_TOKEN_BUG,});const startupWebhook = new Discord.WebhookClient({ id: WEBHOOK_ID_STARTUP, token: WEBHOOK_TOKEN_STARTUP,});
export async function sendException(value: string, shardId?: number) { return exceptionsWebhook .send(`Shard ${shardId}: ${value}`) .catch(doNothingOnError);}export async function sendJoinEvent(value: string, shardId?: number) { return joinsWebhook .send(`Shard ${shardId}: ${value}`) .catch(doNothingOnError);}export async function sendBugreport(value: string, shardId?: number) { return bugreportWebhook .send(`Shard ${shardId}: ${value}`) .catch(doNothingOnError);}export async function sendStartupEvent( shardId: number, justStartingUp = false,) { return startupWebhook .send( justStartingUp ? `Shard ${shardId} is starting...!` : `Shard ${shardId} is up!`, ) .catch(doNothingOnError);}