mirror of
https://github.com/jcreek/denBot.git
synced 2026-07-13 02:43:46 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 76a3431512 | |||
| 3c5aa62d33 | |||
| 62d9df4dcb | |||
| 2a915d9b31 | |||
| 54b30212c8 |
@@ -51,4 +51,6 @@ To access the command line inside the docker container you can run:
|
|||||||
|
|
||||||
`docker exec -it <container id> /bin/bash`
|
`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)
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ const client = new Discord.Client();
|
|||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: 'info',
|
level: 'info',
|
||||||
format: winston.format.json(),
|
format: winston.format.combine(
|
||||||
|
winston.format.timestamp(),
|
||||||
|
winston.format.json()
|
||||||
|
),
|
||||||
defaultMeta: { service: 'user-service' },
|
defaultMeta: { service: 'user-service' },
|
||||||
transports: [
|
transports: [
|
||||||
//
|
//
|
||||||
@@ -67,9 +70,10 @@ function checkQueue(message) {
|
|||||||
message.channel.send(`The adventure is beginning - players should check their DMs\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`);
|
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 randomCode = generateRandomCode();
|
||||||
|
const baseMessage = `@${playerQueue[0].username} is making the lobby. Here is your link code ${randomCode}`;
|
||||||
const adventureMessage = (pokemonName === '' && captainInGameName === '')
|
const adventureMessage = (pokemonName === '' && captainInGameName === '')
|
||||||
? `${generateQueueTitle()}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`
|
? `${generateQueueTitle()}\n${baseMessage}`
|
||||||
: `${generateQueueTitle()}\nPokemon: ${pokemonName}\nCaptain's IGN: ${captainInGameName}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`;
|
: `${generateQueueTitle()}\nPokemon: ${pokemonName}\nCaptain's IGN: ${captainInGameName}\n${baseMessage}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// DM users
|
// DM users
|
||||||
@@ -139,6 +143,7 @@ function makeTempChannel(message, adventureMessage) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
logger.info(`Making temp channel ${channelName}`)
|
||||||
message.guild.channels.create(channelName, {
|
message.guild.channels.create(channelName, {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
permissionOverwrites: permissionOverwrites,
|
permissionOverwrites: permissionOverwrites,
|
||||||
@@ -151,14 +156,19 @@ function makeTempChannel(message, adventureMessage) {
|
|||||||
.catch(logger.error);
|
.catch(logger.error);
|
||||||
|
|
||||||
// Delete the channel after the configured amount of minutes
|
// Delete the channel after the configured amount of minutes
|
||||||
setTimeout(function(){ deleteChannel(message, createdChannelId); }, (config.channeldeletetimeinminutes * 1000 * 60) );
|
setTimeout(function(){ deleteChannel(message, channelName); }, (config.channeldeletetimeinminutes * 1000 * 60) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteChannel(message, channelId) {
|
function deleteChannel(message, channelName) {
|
||||||
// For some reason this errors without the console.log loading the cache first - not sure why
|
try {
|
||||||
console.log(message.guild.channels.cache);
|
// Get a Channel by Name
|
||||||
const fetchedChannel = message.guild.channels.cache.get(channelId);
|
const fetchedChannel = message.guild.channels.cache.find(channel => channel.name === channelName);
|
||||||
fetchedChannel.delete();
|
|
||||||
|
logger.info(`Deleting temp channel ${channelName}`)
|
||||||
|
fetchedChannel.delete();
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client.on('message', function (message) {
|
client.on('message', function (message) {
|
||||||
@@ -286,7 +296,7 @@ client.on('message', function (message) {
|
|||||||
if (command === 'dc') {
|
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
|
// 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)) {
|
if (message.channel.name === getChannelName(message.author.username)) {
|
||||||
deleteChannel(message, message.channel.id)
|
deleteChannel(message, message.channel.name)
|
||||||
logger.log('info', `${message.author.username} deleted their adventure channel.`);
|
logger.log('info', `${message.author.username} deleted their adventure channel.`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user