discohook

1.0.4 • Public • Published

Discohook

version npm github

📥 Installation

$ npm install discohook

or

$ yarn add discohook

Send

😊 Basics

const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

webhook.send({ content: "This is my first message!" }, {
    username: "Discohook Package",
    avatar: "IMAGE_URL"
});

Custom Embeds

const { Webhook, EmbedBuilder } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

const embed = new EmbedBuilder()
.setTitle("The best title!")
.setURL("https://google.com")
.setAuthor("Cool author!", "IMAGE_URL", "https://google.com")
.addField("Field Name", "Field Value", true)
.setDescription("Wow the description")
.setColor("#ff0000")
.setThumbnail("IMAGE_URL")
.setImage("IMAGE_URL")
.setFooter("It's me! A footer", "IMAGE_URL")
.setTimestamp();

webhook.send({ embeds: [embed] });

Note! The maximum amount of embeds in 1 message is 10.

🖱️ Custom Components

const { Webhook, ButtonBuilder, SelectMenuBuilder, ActionRowBuilder } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

const button1 = new ButtonBuilder()
.setStyle("PRIMARY")
.setLabel("This is an button!")
.setEmoji("😊")
.setCustomId("button1")
.setDisabled(false)

const button2 = new ButtonBuilder()
.setStyle("LINK")
.setLabel("Click me to redirect!")
.setURL("https://google.com")

const menu = new SelectMenuBuilder()
.setCustomId("menu")
.setPlaceHolder("This is an placeholder")
.setMinValues(2)
.setMaxValues(3)
.setDisabled(false)
.addOptions([
    {
        label: "First",
        value: "first",
        description: "This is the first option",
        emoji: "1️⃣",
        default: true
    },
    {
        label: "Second",
        value: "second",
        description: "This is the second option",
        emoji: "2️⃣",
        default: false
    },
    {
        label: "Third",
        value: "third",
        description: "This is the third option",
        emoji: "3️⃣",
        default: false
    },
]);

const row1 = new ActionRowBuilder()
.addComponents([button1, button2]);

const row2 = new ActionRowBuilder()
.setComponents([menu]);

webhook.send({ content: "Epic components!", components: [row1, row2] });

Note! A message can have an maximum amount of 5 rows. 1 row can include 1 SelectMenu or 5 Buttons.

📂 Sending Files

const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

webhook.send({ files: [{
    attachment: "path/to/file.png",
    name: "file.png"
}]});

✏️ Edit

const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

webhook.send({ content: "This message will be editted in 5 seconds.." })
.then(message => {
    setTimeout(() => {
        webhook.edit(message.id, { content: "Editted!" });
    }, 5000);
});

🗑️ Delete

const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

webhook.send({ content: "This message will be deleted in 5 seconds.." })
.then(message => {
    setTimeout(() => {
        webhook.delete(message.id);
    }, 5000);
});

Webhook

👋 setUsername

const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

webhook.setUsername("Discohook Package");
console.log("Changed the webhook's default username!");

🖼️ setAvatar

const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

webhook.setAvatar("IMAGE_URL");
console.log("Changed the webhook's default avatar!");

ℹ️ getInfo

const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");

webhook.getInfo().then(console.log)

Classes

🪝 Webhook

Constructor

  • Webhook URL: String

Methods

  • setUsername(username: String)
  • setAvatar(avatar: String)
  • getInfo() returns Webhook
  • send({ content: String, embeds: EmbedBuilder[], components: ActionRowBuilder[], files: file[], tts: Boolean }, { username (optional): String, avatar_url (optional): String }) returns Message
  • edit(messageID: String, { content: String, embeds: EmbedBuilder[], components: ActionRowBuilder[], files: file[], tts: Boolean }, { username: String, avatar_url: String }) returns Message
  • delete(messageID: String)

EmbedBuilder

Methods

  • setTitle(title: String)
  • setDescription(description: String)
  • setColor(color: String (Hex Color / Color Name))
  • addField(name: String, value: String, inline (optional): Boolean)
  • setImage(image: String)
  • setThumbnail(thumbnail: String)
  • setURL(url: String)
  • setFooter(footer: String, url (optional): String)
  • setTimestamp(timestamp (optional): Integer/Number/Date)
  • setAuthor(author: String, img (optional): String, url (optional): String)

🖱️ ButtonBuilder

Methods

  • setStyle(style: ButtonStyle)
  • setLabel(label: String)
  • setEmoji(emoji: String/Snowflake)
  • setCustomId(id: String)
  • setURL(url: String)
  • setDisabled(disabled: Boolean)

🔢 SelectMenuBuilder

Methods

  • setCustomId(id: String)
  • setPlaceholder(placeholder: String)
  • setMinValues(min: Integer)
  • setMaxValues(max: Integer)
  • setDisabled(disabled: Boolean)
  • addOptions(Options[])

🧍‍♂️🧍🧍‍♀️ ActionRowBuilder

Methods

  • addComponents(ButtonBuilder[] / SelectMenuBuilder)
  • setComponents(ButtonBuilder[] / SelectMenuBuilder)

📝 License

MIT

Package Sidebar

Install

npm i discohook

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

25.1 kB

Total Files

14

Last publish

Collaborators

  • koenie06