EnqueueMe is a discord bot that can be used to manage a queue. Server members are able to enqueue by typing /qme, leave the queue by typing /cancel. An enqueued member is able to check how many people are before him in the queue. Server members with a specific role are able to select members from the queue. The queue is persisted in a file. The communication with the bot can be limited to specific channels/categories by using a config.json file.
Setup up a bot in the discord.js console, following the official guide.
Put a configuration file into the project root named config.json
with following content:
{
"prefix": "a prefix to use like '/'",
"token": "the bot token",
"adminRole": "the admin role to allow query queue information from the bot",
"channels": {
"category": "the default category anme under which the channels are listed, no category to allow communication on every channel.",
"member": "the default member channel name",
"admin": "the default admin channel name"
}
}
There are different possibilities to configure the channels to be used for communication with the bot. Here are a few.
"category": "bot",
"member": ["member", "test", "something else"],
"admin": "admin"
Added | Command | Parameters | Effect |
---|---|---|---|
/qme | - | Enqueues the user calling | |
/cancel | - | Remove the calling user from the queue | |
/next | - | Dequeues the next user from a queue. Only callable by members who'm are given appropriate role (configured in ./config.json as adminRole) |
|
/putback | - | Puts a user back into the queue | |
/list | - | Returns the position of the user in the queue | |
/listen | - | stop | If a user enqueues the user who called this command will be informed | |
/peek | - | | all | Peeks into the queue for x-positions from the head of the queue. | |
/help | - | Prints a help for the bot commands |
To define new commands you need to create a new file in the /commands
directory for each command. You can define a command by subclassing from the Command class located in./core/command.js
. The constructor takes in the storage object and the file-name as parameteres on initialization. The fileName represents the command name and defaults to the name of the file, without the file extension (.js). Overwriting the command name, setting command specific options and response messages can be done inside the ./commands/defintions.json
. For more information you can check below.
You can use the following boilerplate to define a new command.
const Command = require('../core/command');
class CommandName extends Command {
constructor(storage, fileName) {
super(fileName);
this.storage = storage;
}
/**
*
* @param {Object} message - The deafult discord message object encapsulating the user request
* @param {String[]} args - Additional arguments passed with a message call as an array.
*
*/
execute(message, args) {
// Command specific code here
// To get responses defined in ./definitions.json call (inherited from ./core/command.js)
let responseMessage = this.getReponse("responseKey", param1, param2, ...)
// You can return a message like this. Check the discord.js documentation for more information 'message.reply("")' for private messages
return message.channel.send("Hello World.");
}
}
module.exports = CommandName;
The bot.js
script pulls all files from ./commands
that end with .js, loading the commands automatically. After defining the command you need to extend the
You can modify the name used for the command by creating a new entry in the ./commands/definitions.json
file, the name overwrites
Right below you see an example entry for an imaginary command defined in ./commands/example.js
.
{
"example": { // The name of the file
"name": "ping", // The name of the command by which it can be called inside of discord
"asAdmin": false, // Only useable by bot admins
"responses": {
"success": "<@{0}>, pong!",
"error": "<@{0}, I couldn't fullfill your request, Try to contact <@{1}>."
}
}
}