Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save StianWiu/0bd2c3f9dcccda5a46961951543e28f7 to your computer and use it in GitHub Desktop.
Save StianWiu/0bd2c3f9dcccda5a46961951543e28f7 to your computer and use it in GitHub Desktop.
This code will take in arguments like --name so you can customize what to send from your terminal
import { Webhook, MessageBuilder } from 'discord-webhook-node';
const hook = new Webhook("DISCORD WEBHOOK HERE"); // Change this to your webhook. (this is a example url, it doesn't work)
import { Command } from "commander";
const program = new Command();
program.option("-n, --name <string>"); // You can add more options here following the same format.
program.option("-z, --size <string>");
program.option("-f, --path <string>");
program.parse(process.argv);
const options = program.opts();
hook.send("<@CLIENT ID IF YOU WANT TO BE @ WHEN MESSAGE IS SENT>"); // Change the number with your client id so it can notify you.
const embed = new MessageBuilder()
.setTitle(`${options.name} has finished downloading`)
.addField('Size:', `${options.size}`)
.addField('Path:', `${options.path}`) // You can add more fields following the same format.
.setColor('#00b0f4') // See https://www.npmjs.com/package/discord-webhook-node for more options in your embed.
.setTimestamp();
hook.send(embed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment