
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
discord-hook-api
Advanced tools
A Node.js Module to post to Discord Webhooks.
Check the example.js
in the examples
folder
Simply run
npm i discord-hook-api
or yarn add discord-hook-api
Put this somewhere on the top of your document
const { Hook, Embed } = require('discord-hook-api')
To get started, you need to give up the webhook URL and append the methods using .method(argument)
on the next lines.
webhook(url)
Pass the url for the webhook, there are two ways to pass it.
Argument(s): string
new Hook()
.webhook(webhook_url_here)
// or
new Hook(webhook_url_here)
addEmbed(embed)
Simply add an embed to the post by using the addElement
method, you pass an embed which you can make as well. More information later in this documenation.
Argument(s): embed
new Hook()
.addEmbed(embed)
setAvatar(avatar)
Overwrite the avatar set in the webhook settings on Discord, you need to pass an URL to it which directly leads to a file. You can use something like file.coffee for it.
Argument(s): string
new Hook()
.setAvatar(url)
setContent(content)
This is the message you want to display, you can leave it blank if you are gonna send an embed.
Argument(s): string
new Hook()
.setAvatar(content)
setUsername(username)
Overwrite the username set in the webhook settings on Discord, you need to pass a string.
Argument(s): string
new Hook()
.setUsername(username)
setTts()
Want to make the webhook speak to all it's users, you can do it.
Argument(s): none
new Hook()
.setTts(boolean)
send()
Done making the message? Run this method and it will be delivered to Discord.
Argument(s): none
new Hook()
.send()
Want to send a fancy message? The Embed class got you covered. Start with the following and append the methods using .method(argument)
on the next lines.
const embed = new Embed()
setTitle(title)
Set the title of the embed
Argument(s): string
const embed = new Embed()
.setTitle(title)
setDescription(description)
Set the description of the embed
Argument(s): string
const embed = new Embed()
.setDescription(description)
setUrl(url)
Set the url of the embed
Argument(s): string
const embed = new Embed()
.setUrl(url)
setTimestamp(timestamp)
Set the timestamp for the footer of the timestamp, you don't need to pass an argument and it will pick the current time.
Argument(s): string
const embed = new Embed()
.setTimestamp(timestamp)
setColor(setColor)
Set the color of the embed
Argument(s): integer
const embed = new Embed()
.setColor(setColor)
setFooter(text, icon)
Set the footer of the embed, the icon is optional if you are using this method.
Argument(s): string, string
const embed = new Embed()
.setFooter(text, icon)
setImage(url)
Set the image of the embed
Argument(s): string
const embed = new Embed()
.setImage(url)
setThumbnail(url)
Set the thumbnail of the embed
Argument(s): string
const embed = new Embed()
.setThumbnail(url)
setVideo(url)
Set the video of the embed
Argument(s): string
const embed = new Embed()
.setVideo(url)
setAuthor(name, icon, url)
Set the author of the embed, icon and url are optional.
Argument(s): string, string, string
const embed = new Embed()
.setAuthor(name, icon, url)
addField(name, value, inline)
Add a field to the embed, max is 25 fields.
Argument(s): string
const embed = new Embed()
.addField(name, value, inline)
Released under the MIT
License
FAQs
A Node.js Module to post to Discord Webhooks
The npm package discord-hook-api receives a total of 1 weekly downloads. As such, discord-hook-api popularity was classified as not popular.
We found that discord-hook-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.