Releases: SCDerox/simple-discord-webhooks
Releases · SCDerox/simple-discord-webhooks
v2.1.0
What's Changed
- add get() method by @itzTheMeow in #7
New Contributors
- @itzTheMeow made their first contribution in #7
Full Changelog: v2.0.0...v2.1.0
v2.0.0
- Support for Typescript & Custom Error-Type
Full Changelog: v1.1.1...v2.0.0
v1.1.1
v1.1.0
v1.1.0 (October 5, 2021)
- Added support for
PATCH /webhooks/{webhook.id}/{webhook.token}
Discord-API-Call: You can now modify the username or avatar of your webhook user - Added support for
DELETE /webhooks/{webhook.id}/{webhook.token}
Discord-API-Call: You can now delete your webhook - Added support for
GET https://discord.com/developers/docs/resources/webhook#edit-webhook-message
Discord-API-Call: You can now fetch an already sent webhook message (including content) - Added support for Message-Component-Object. ⚠ This will only work, if your webhook is owned by an application.
Read more in the CHANGELOG.
First Version (with a bug fix)
simple-discord-webhooks
Features
- Send webhook messages
- Edit webhook messages
- Delete webhook messages
- Support for custom avatarUrl and username
- Support for Embed-Objects
- Support for Allowed-Mentions-Object
Install from NPM
$ npm i simple-discord-webhooks --save
Example Usage
const {Webhook} = require('simple-discord-webhooks');
const webhook = new Webhook('https://discord.com/api/webhooks/820304489637871657/QPZWXNS6wUsQ7iKA-Sm7YDIODCbxk60WNeRDoPtEOxZaMvlqbrM_1LQ_LVZHMNhbdz6N');
webhook.send('This message should get edited (hopefully) soon').then(async (result) => {
setTimeout(async () => {
await result.edit('And should get deleted (hopefully) soon');
console.log('Successfully edited send message!');
}, 3000);
setTimeout(async () => {
await result.delete();
console.log('Successfully deleted send message!');
}, 6000);
});
const message = webhook.resolveMessageID('820311219432194068');
message.edit('Hello there!').then(() => console.log('Edited message'))
API
-
Class:
Webhook(url, username = null, avatarUrl = null)
- function
send(content, embeds = [], allowedMentions = {}, tts = false)
- Sends a message- content (string): Content of the message
- embeds (array, optional): Array
of Embed-Objects - allowedMentions (object, optional):
A Allowed-Mentions-Object - tts (boolean, optional): Set to
true
to enable TTS. - Returns
Promise<Message>
(with all the values
from here)
- function
resolveMessageID(messageID)
- Returns a MessageObject of a Message-ID- messageID(string): ID of a message send by this webhook
- Returns
Message
- NOTE: You can only get a
Message
-Object with to edit and delete the message - You can not (!) get the
content of it.
- function
-
Class:
Message(messageData, webhookurl)
messageData
(object) has to have a value calledid
with the id of the message in it- function
delete()
- Deletes the message- Returns
Promise<boolean>
(true if everything went smoothly.)
- Returns
- function
edit(content, embeds = [], allowedMentions = {})
- Edits the message- content (string): Content of the message
- embeds (array, optional): Array
of Embed-Objects - allowedMentions (object, optional):
A Allowed-Mentions-Object - Returns
Promise<Message>
(with all the values
from here)
Questions or suggestions?
Feel free to send me a DM on Discord: SCDerox#4645
Contributing
Feel free to create any issues and PRs in our github repository if you
want to contribute.
© Simon Csaba, 22021 | mail[at]scderox.de
First Version
simple-discord-webhooks
Features
- Send webhook messages
- Edit webhook messages
- Delete webhook messages
- Support for custom avatarUrl and username
- Support for Embed-Objects
- Support for Allowed-Mentions-Object
Install from NPM
$ npm i simple-discord-webhooks --save
Example Usage
const {Webhook} = require('../Webhook');
const webhook = new Webhook('https://discord.com/api/webhooks/820304489637871657/QPZWXNS6wUsQ7iKA-Sm7YDIODCbxk60WNeRDoPtEOxZaMvlqbrM_1LQ_LVZHMNhbdz6N');
webhook.send('This message should get edited (hopefully) soon').then(async (result) => {
setTimeout(async () => {
await result.edit('And should get deleted (hopefully) soon');
console.log('Successfully edited send message!');
}, 3000);
setTimeout(async () => {
await result.delete();
console.log('Successfully deleted send message!');
}, 6000);
});
const message = webhook.resolveMessageID('820311219432194068');
message.edit('Hello there!').then(() => console.log('Edited message'))
API
-
Class:
Webhook(url, username = null, avatarUrl = null)
- function
send(content, embeds = [], allowedMentions = {}, tts = false)
- Sends a message- content (string): Content of the message
- embeds (array, optional): Array
of Embed-Objects - allowedMentions (object, optional):
A Allowed-Mentions-Object - tts (boolean, optional): Set to
true
to enable TTS. - Returns
Promise<Message>
(with all the values
from here)
- function
resolveMessageID(messageID)
- Returns a MessageObject of a Message-ID- messageID(string): ID of a message send by this webhook
- Returns
Message
- NOTE: You can only get a
Message
-Object with to edit and delete the message - You can not (!) get the
content of it.
- function
-
Class:
Message(messageData, webhookurl)
messageData
(object) has to have a value calledid
with the id of the message in it- function
delete()
- Deletes the message- Returns
Promise<boolean>
(true if everything went smoothly.)
- Returns
- function
edit(content, embeds = [], allowedMentions = {})
- Edits the message- content (string): Content of the message
- embeds (array, optional): Array
of Embed-Objects - allowedMentions (object, optional):
A Allowed-Mentions-Object - Returns
Promise<Message>
(with all the values
from here)
Questions or suggestions?
Feel free to send me a DM on Discord: SCDerox#4645
Contributing
Feel free to create any issues and PRs in our github repository if you
want to contribute.
© Simon Csaba, 22021 | mail[at]scderox.de