mirror of
https://github.com/jcreek/denBot.git
synced 2026-07-13 02:43:46 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f683386583 | |||
| 4035abf933 | |||
| 22529d38a0 | |||
| f4b55bcd11 | |||
| b4ee73da0e | |||
| fb2203308d | |||
| 9fc701406d | |||
| 0f5d9278eb |
@@ -15,6 +15,8 @@ Commands:
|
||||
* 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)
|
||||
* help - Show all user commands
|
||||
* adminhelp - Show all admin commands
|
||||
|
||||
## Installing Docker
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"maxqueuesize": 4,
|
||||
"channeldeletetimeinminutes": 20,
|
||||
"channeldeletetimeinminutes": 30,
|
||||
"deletecommandstoggle": false,
|
||||
"maxqueuesize": 4,
|
||||
"prefix": "!",
|
||||
"token": "NzcwMDQyMDEzMjY5NDkxNzUy.X5Xzgg.kcr_51g95iUvEcYCfbQvG1Sx8ao"
|
||||
}
|
||||
|
||||
@@ -66,23 +66,22 @@ function checkQueue(message) {
|
||||
// Post a message to say the queue is complete
|
||||
message.channel.send(`The adventure is beginning - players should check their DMs\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`);
|
||||
|
||||
const randomCode = generateRandomCode();
|
||||
const adventureMessage = (pokemonName === '' && captainInGameName === '')
|
||||
? `${generateQueueTitle()}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`
|
||||
: `${generateQueueTitle()}\nPokemon: ${pokemonName}\nCaptain's IGN: ${captainInGameName}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`;
|
||||
|
||||
try {
|
||||
// DM users
|
||||
const randomCode = generateRandomCode();
|
||||
playerQueue.forEach(player => {
|
||||
if (pokemonName === '' && captainInGameName === '') {
|
||||
client.users.cache.get(player.id).send(`${generateQueueTitle()}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`);
|
||||
}
|
||||
else {
|
||||
client.users.cache.get(player.id).send(`${generateQueueTitle()}\nPokemon: ${pokemonName}\nCaptain's IGN: ${captainInGameName}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`);
|
||||
}
|
||||
client.users.cache.get(player.id).send(adventureMessage);
|
||||
});
|
||||
} catch (error) {
|
||||
logger.log('error', error);
|
||||
message.channel.send(`There was an error, please let an admin know!\n${error}`);
|
||||
}
|
||||
|
||||
makeTempChannel(message);
|
||||
makeTempChannel(message, adventureMessage);
|
||||
|
||||
// Clear the queue
|
||||
playerQueue = [];
|
||||
@@ -122,8 +121,8 @@ function getChannelName(username) {
|
||||
return `${username}s-adventurers`;
|
||||
}
|
||||
|
||||
function makeTempChannel(message) {
|
||||
const channelName = getChannelName(message.author.username);
|
||||
function makeTempChannel(message, adventureMessage) {
|
||||
const channelName = getChannelName(playerQueue[0].username);
|
||||
let createdChannelId = '';
|
||||
let everyoneRole = message.guild.roles.cache.find(r => r.name === '@everyone');
|
||||
|
||||
@@ -143,14 +142,21 @@ function makeTempChannel(message) {
|
||||
message.guild.channels.create(channelName, {
|
||||
type: 'text',
|
||||
permissionOverwrites: permissionOverwrites,
|
||||
}).then(createdChannel => { createdChannelId = createdChannel.id; })
|
||||
}).then(createdChannel => {
|
||||
createdChannelId = createdChannel.id;
|
||||
|
||||
// Post in the channel
|
||||
createdChannel.send(adventureMessage);
|
||||
})
|
||||
.catch(logger.error);
|
||||
|
||||
// Delete the channel after 20 seconds
|
||||
// Delete the channel after the configured amount of minutes
|
||||
setTimeout(function(){ deleteChannel(message, createdChannelId); }, (config.channeldeletetimeinminutes * 1000 * 60) );
|
||||
}
|
||||
|
||||
function deleteChannel(message, channelId) {
|
||||
// For some reason this errors without the console.log loading the cache first - not sure why
|
||||
console.log(message.guild.channels.cache);
|
||||
const fetchedChannel = message.guild.channels.cache.get(channelId);
|
||||
fetchedChannel.delete();
|
||||
}
|
||||
@@ -280,7 +286,7 @@ client.on('message', function (message) {
|
||||
if (command === 'dc') {
|
||||
// todo - add logic here to determine if they can delete the channel (i.e. it's their temporary one) - compare the name
|
||||
if (message.channel.name === getChannelName(message.author.username)) {
|
||||
deleteChannel(message.channel.id)
|
||||
deleteChannel(message, message.channel.id)
|
||||
logger.log('info', `${message.author.username} deleted their adventure channel.`);
|
||||
}
|
||||
else {
|
||||
@@ -288,4 +294,32 @@ client.on('message', function (message) {
|
||||
logger.log('info', `${message.author.username} attempted to delete channel ${message.channel.id} but it's not their adventure channel.`);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
`;
|
||||
|
||||
message.channel.send(msg);
|
||||
}
|
||||
|
||||
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)
|
||||
`;
|
||||
|
||||
message.channel.send(msg);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user