mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 04:52:22 +00:00
3.1.4 - finalised message queueing
This commit is contained in:
parent
be0be60947
commit
68fd2ee9dd
5 changed files with 40 additions and 6 deletions
34
README.md
34
README.md
|
|
@ -55,6 +55,40 @@ Here is a list of other Discord APIs:
|
|||
|
||||
---
|
||||
|
||||
### Changes in 3.1.4
|
||||
|
||||
No, not π. But instead, pseduo-synchronous messaging was added! This means that
|
||||
you can tell your Client to make a queue of "actions" per channel, and it will
|
||||
work through them one by one. This is a really useful tool if you need to send
|
||||
messages in a specific order without callback hell.
|
||||
|
||||
It also allows you to store responses - such as created messages - in the returned
|
||||
promise - named action. Example:
|
||||
|
||||
```js
|
||||
var mybot = new Discord.Client({
|
||||
queue : true //enable queueing, disabled by default
|
||||
});
|
||||
|
||||
mybot.on("message", function(msg){
|
||||
|
||||
mybot.sendMessage(msg.channel, "this is message 1");
|
||||
var action = mybot.sendMessage(msg.channel, "this is message 2");
|
||||
mybot.sendMessage(msg.channel, "this is message 3").then(rmv);
|
||||
|
||||
function rmv(){
|
||||
if(!action.error){
|
||||
mybot.deleteMessage(action.message);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
This is still in development, and will see many more enhancements in future.
|
||||
|
||||
---
|
||||
|
||||
### Links
|
||||
**[Documentation](https://github.com/discord-js/discord.js/wiki/Documentation)**
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ var WebSocket = require("ws");
|
|||
var fs = require("fs");
|
||||
|
||||
var defaultOptions = {
|
||||
queue: []
|
||||
queue: false
|
||||
};
|
||||
|
||||
var Client = (function () {
|
||||
|
|
@ -35,7 +35,7 @@ var Client = (function () {
|
|||
further efforts will be made to connect.
|
||||
*/
|
||||
this.options = options;
|
||||
this.options.queue = this.options.queue || [];
|
||||
this.options.queue = this.options.queue;
|
||||
this.token = token;
|
||||
this.state = 0;
|
||||
this.websocket = null;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "discord.js",
|
||||
"version": "3.1.3",
|
||||
"version": "3.1.4",
|
||||
"description": "A way to interface with the Discord API",
|
||||
"main": "./lib/index.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ var WebSocket = require("ws");
|
|||
var fs = require("fs");
|
||||
|
||||
var defaultOptions = {
|
||||
queue: []
|
||||
queue: false
|
||||
}
|
||||
|
||||
class Client {
|
||||
|
|
@ -25,7 +25,7 @@ class Client {
|
|||
further efforts will be made to connect.
|
||||
*/
|
||||
this.options = options;
|
||||
this.options.queue = this.options.queue || [];
|
||||
this.options.queue = this.options.queue;
|
||||
this.token = token;
|
||||
this.state = 0;
|
||||
this.websocket = null;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var Discord = require("../");
|
||||
var mybot = new Discord.Client({
|
||||
queue: ["send"]
|
||||
queue: true
|
||||
});
|
||||
var fs = require("fs");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue