Skip to content

Instantly share code, notes, and snippets.

@GoodnessEzeokafor
Created August 16, 2023 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoodnessEzeokafor/966abe973706c60f94009dcfcfb40d1e to your computer and use it in GitHub Desktop.
Save GoodnessEzeokafor/966abe973706c60f94009dcfcfb40d1e to your computer and use it in GitHub Desktop.
Discord
import { Webhook, MessageBuilder } from 'discord-webhook-node';
export type IDiscord = { link?: string, title?: string, author?: string, message?: string }
async sendToDiscord(payload: IDiscord) {
// send to discord
const { link, title, author, message } = payload;
try {
const hook = new Webhook(link);
const embed = await new MessageBuilder()
.setTitle(title)
.setAuthor(author || PLATFORM_NAME)
.setDescription(message);
hook.send(embed);
Logger.log('Discord notification sent');
} catch (e) {
Logger.error('@discord', e);
throw new Error(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment