![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@prince25/discord-webhook-sender
Advanced tools
Allows for easy webhook sending through discord's webhook API
This is an updated version of the original package made by matthew1232.
Since that package hasn't been updated recently, I decided to make a fork.
npm install discord-webhook-sender
or yarn add discord-webhook-sender
const { Webhook } = require('discord-webhook-sender');
const hook = new Webhook("YOUR WEBHOOK URL");
const IMAGE_URL = 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png';
hook.setUsername('Discord Webhook Node Name');
hook.setAvatar(IMAGE_URL);
hook.send("Hello there!");
const { Webhook, MessageBuilder } = require('discord-webhook-sender');
const hook = new Webhook("YOUR WEBHOOK URL");
const embed = new MessageBuilder()
.setTitle('My title here')
.setAuthor('Author here', 'https://cdn.discordapp.com/embed/avatars/0.png', 'https://www.google.com')
.setURL('https://www.google.com')
.addField('First field', 'this is inline', true)
.addField('Second field', 'this is not inline')
.setColor('#00b0f4')
.setThumbnail('https://cdn.discordapp.com/embed/avatars/0.png')
.setDescription('Oh look a description :)')
.setImage('https://cdn.discordapp.com/embed/avatars/0.png')
.setFooter('Hey its a footer', 'https://cdn.discordapp.com/embed/avatars/0.png')
.setTimestamp();
hook.send(embed);
Keep in mind that the custom embed method setColor
takes in a decimal color/a hex color (pure black and white hex colors will be innacurate). You can convert colors to decimal or hex using this website here: https://convertingcolors.com
const { Webhook } = require('discord-webhook-sender');
const hook = new Webhook('YOUR WEBHOOK URL');
hook.sendFile('../yourfilename.png');
const { Webhook } = require('discord-webhook-sender');
const hook = new Webhook('YOUR WEBHOOK URL');
// Sends an information message
hook.info('**Information hook**', 'Information field title here', 'Information field value here');
// Sends a success message
hook.success('**Success hook**', 'Success field title here', 'Success field value here');
// Sends an warning message
hook.warning('**Warning hook**', 'Warning field title here', 'Warning field value here');
// Sends an error message
hook.error('**Error hook**', 'Error field title here', 'Error field value here');
const { Webhook } = require('discord-webhook-sender');
const hook = new Webhook({
url: "YOUR WEBHOOK URL",
// If throwErrors is set to false, no errors will be thrown if there is an error sending
throwErrors: false,
// retryOnLimit gives you the option to not attempt to send the message again if rate limited
retryOnLimit: false,
// If a HTTP proxy is proxy, it will send the hook via that proxy
// Use the format, "ip:port", for IP-based authentication proxies or username:password@ip:port
proxy: "123.456.789.10:1112"
});
hook.setUsername('Username'); // Overrides the default webhook username
hook.setAvatar('YOUR_AVATAR_URL'); // Overrides the default webhook avatar
discord-webhook-sender is a promise based library, which means you can use .catch
, .then
, and await
, although if successful will not return any values. For example:
const { Webhook } = require('discord-webhook-sender');
const hook = new Webhook("YOUR WEBHOOK URL");
hook.send("Hello there!")
.then(() => console.log('Sent webhook successfully!'))
.catch(err => console.log(err.message));
or using async:
const { Webhook } = require('discord-webhook-sender');
const hook = new Webhook("YOUR WEBHOOK URL");
(async () => {
try {
await hook.send('Hello there!');
console.log('Successfully sent webhook!');
}
catch(e){
console.log(e.message);
};
})();
By default, it will handle Discord's rate limiting, and if there is an error sending the message (other than rate limiting), an error will be thrown. You can change these options with the custom settings options below.
Constructor
Methods
Methods
MIT
FAQs
Allows for easy webhook sending through discord's webhook API
We found that @prince25/discord-webhook-sender 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.