discohook
v1.0.4
Published
A package to send/edit/delete webhook messages.
Downloads
8
Maintainers
Readme
Discohook
$ npm install discohook
or
$ yarn add discohook
const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");
webhook.send({ content: "This is my first message!" }, {
username: "Discohook Package",
avatar: "IMAGE_URL"
});
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.
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.
const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");
webhook.send({ files: [{
attachment: "path/to/file.png",
name: "file.png"
}]});
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);
});
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);
});
const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");
webhook.setUsername("Discohook Package");
console.log("Changed the webhook's default username!");
const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");
webhook.setAvatar("IMAGE_URL");
console.log("Changed the webhook's default avatar!");
const { Webhook } = require("discohook");
const webhook = new Webhook("WEBHOOK URL");
webhook.getInfo().then(console.log)
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)
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)
Methods
- setStyle(style: ButtonStyle)
- setLabel(label: String)
- setEmoji(emoji: String/Snowflake)
- setCustomId(id: String)
- setURL(url: String)
- setDisabled(disabled: Boolean)
Methods
- setCustomId(id: String)
- setPlaceholder(placeholder: String)
- setMinValues(min: Integer)
- setMaxValues(max: Integer)
- setDisabled(disabled: Boolean)
- addOptions(Options[])
Methods
- addComponents(ButtonBuilder[] / SelectMenuBuilder)
- setComponents(ButtonBuilder[] / SelectMenuBuilder)
MIT