mirror of
https://github.com/jcreek/denBot.git
synced 2026-07-13 02:43:46 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4429e02b22 | |||
| 49cd612f51 | |||
| f6af7b4327 | |||
| 01768c5567 | |||
| 9700808773 | |||
| 857ee29e10 |
@@ -12,6 +12,7 @@ Commands:
|
||||
* q pokemon ign - Join the queue (first player can set the pokemon and their in-game name)
|
||||
* lq - Leave the queue
|
||||
* sq - Show the queue
|
||||
* start - Vote to start the adventure early, without the full number of players (all players in the queue must use this to start early)
|
||||
* cq - Clear the queue (admin-only, not to be shared with normal users)
|
||||
* ru - Remove a tagged user from the queue (admin-only, not to be shared with normal users)
|
||||
* dc - Delete an adventure channel (only the captain can use this)
|
||||
@@ -50,7 +51,3 @@ If you want more of a sanity check here are some following commands you can run
|
||||
To access the command line inside the docker container you can run:
|
||||
|
||||
`docker exec -it <container id> /bin/bash`
|
||||
|
||||
## Version 2.0 potential features
|
||||
|
||||
* Let three people agree to start early using a voting command, so they don't have to wait for a fourth person (all three must vote to start)
|
||||
|
||||
@@ -78,6 +78,7 @@ const logger = winston.createLogger({
|
||||
//}
|
||||
|
||||
let playerQueue = [];
|
||||
let playerVotes = [];
|
||||
let pokemonName = '';
|
||||
let captainInGameName = '';
|
||||
|
||||
@@ -110,7 +111,7 @@ function generateRandomCode() {
|
||||
}
|
||||
|
||||
function checkQueue(message) {
|
||||
if (playerQueue.length === config.maxqueuesize) {
|
||||
if (playerQueue.length === config.maxqueuesize || (playerQueue.length > 0 && playerQueue.length == playerVotes.length)) {
|
||||
// Queue is full
|
||||
logger.log('info', 'Queue is full');
|
||||
|
||||
@@ -174,7 +175,7 @@ function getUserFromMention(mention) {
|
||||
}
|
||||
|
||||
function getChannelName(username) {
|
||||
return `${username}s-adventurers`;
|
||||
return `${username.toLowerCase()}s-adventurers`;
|
||||
}
|
||||
|
||||
function makeTempChannel(message, adventureMessage) {
|
||||
@@ -285,15 +286,22 @@ client.on('message', function (message) {
|
||||
|
||||
logger.info(`${message.author.username} used command lq in ${message.channel.name}`);
|
||||
|
||||
logger.log('info', `${message.author.username} left the queue.`);
|
||||
message.channel.send(`${message.author.username} left the queue.`);
|
||||
|
||||
for( var i = 0; i < playerQueue.length; i++){
|
||||
if ( playerQueue[i] === message.author) {
|
||||
playerQueue.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( var i = 0; i < playerVotes.length; i++){
|
||||
if ( playerVotes[i] === message.author) {
|
||||
playerVotes.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log('info', `${message.author.username} left the queue.`);
|
||||
message.channel.send(`${message.author.username} left the queue.`);
|
||||
|
||||
checkQueue(message);
|
||||
}
|
||||
@@ -308,6 +316,42 @@ client.on('message', function (message) {
|
||||
message.channel.send(`${message.author.username} you can't leave the queue before you've joined it!`);
|
||||
}
|
||||
|
||||
// Vote to start early with only the users currently in the queue
|
||||
if(command === 'start') {
|
||||
// Delete the message with the bot command
|
||||
if (config.deletecommandstoggle) {
|
||||
message.delete();
|
||||
}
|
||||
|
||||
logger.info(`${message.author.username} used command ${command} in ${message.channel.name}`);
|
||||
|
||||
if(playerQueue.length == 0) {
|
||||
message.channel.send(`You can only vote to start an adventure early if there is a queue. You can start a queue by using the command ${config.prefix}help`);
|
||||
}
|
||||
else if(playerVotes.length == 0) {
|
||||
// First player to vote
|
||||
playerVotes.push(message.author);
|
||||
|
||||
message.channel.send(`=====\n${message.author.username} voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${config.maxqueuesize} players.`);
|
||||
}
|
||||
else if (playerVotes.includes(message.author.username)) {
|
||||
message.channel.send(`=====\n${message.author.username} has already voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${config.maxqueuesize} players.`);
|
||||
}
|
||||
else if (playerVotes.length < config.maxqueuesize) {
|
||||
// Not the first player to vote
|
||||
playerVotes.push(message.author);
|
||||
|
||||
if (playerVotes.length < playerQueue.length) {
|
||||
// Still not all players voted
|
||||
message.channel.send(`=====\n${message.author.username} voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${config.maxqueuesize} players.`);
|
||||
}
|
||||
else {
|
||||
// All players have voted, we can start the adventure early
|
||||
checkQueue(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show the queue
|
||||
if(command === 'sq') {
|
||||
// Delete the message with the bot command
|
||||
@@ -361,6 +405,13 @@ client.on('message', function (message) {
|
||||
}
|
||||
}
|
||||
|
||||
for( var i = 0; i < playerVotes.length; i++){
|
||||
if ( playerVotes[i].username === user.username) {
|
||||
playerVotes.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
message.channel.send(`${user.username} removed from queue.`);
|
||||
logger.log('info', `${message.author.username} removed ${user.username} from queue.`);
|
||||
|
||||
@@ -389,11 +440,12 @@ client.on('message', function (message) {
|
||||
if (command === 'help') {
|
||||
let msg = `
|
||||
The commands available to you are:
|
||||
- !q - Join the queue
|
||||
- !q <pokemon> <ign> - Join the queue (first player can set the pokemon and their in-game name)
|
||||
- !lq - Leave the queue
|
||||
- !sq - Show the queue
|
||||
- !dc - Delete an adventure channel (only the captain can use this)
|
||||
- ${command}q - Join the queue
|
||||
- ${command}q <pokemon> <ign> - Join the queue (first player can set the pokemon and their in-game name)
|
||||
- ${command}lq - Leave the queue
|
||||
- ${command}sq - Show the queue
|
||||
- ${command}start - Vote to start the adventure early, without the full number of players (all players in the queue must use this to start early)
|
||||
- ${command}dc - Delete an adventure channel (only the captain can use this)
|
||||
`;
|
||||
|
||||
message.channel.send(msg);
|
||||
@@ -402,13 +454,14 @@ The commands available to you are:
|
||||
if (command === 'adminhelp') {
|
||||
let msg = `
|
||||
The commands available to you are:
|
||||
- !q - Join the queue
|
||||
- !q <pokemon> <ign> - Join the queue (first player can set the pokemon and their in-game name)
|
||||
- !lq - Leave the queue
|
||||
- !sq - Show the queue
|
||||
- !cq - Clear the queue (admin-only, not to be shared with normal users)
|
||||
- !ru - Remove a tagged user from the queue (admin-only, not to be shared with normal users)
|
||||
- !dc - Delete an adventure channel (only the captain can use this)
|
||||
- ${command}q - Join the queue
|
||||
- ${command}q <pokemon> <ign> - Join the queue (first player can set the pokemon and their in-game name)
|
||||
- ${command}lq - Leave the queue
|
||||
- ${command}sq - Show the queue
|
||||
- ${command}start - Vote to start the adventure early, without the full number of players (all players in the queue must use this to start early)
|
||||
- ${command}cq - Clear the queue (admin-only, not to be shared with normal users)
|
||||
- ${command}ru - Remove a tagged user from the queue (admin-only, not to be shared with normal users)
|
||||
- ${command}dc - Delete an adventure channel (only the captain can use this)
|
||||
`;
|
||||
|
||||
message.channel.send(msg);
|
||||
|
||||
Reference in New Issue
Block a user