mirror of
https://github.com/jcreek/denBot.git
synced 2026-07-13 19:03:45 +00:00
feat(*): Add functionality to create temp text channel for completed queue members
This commit is contained in:
@@ -74,6 +74,8 @@ function checkQueue(message) {
|
|||||||
message.channel.send(`There was an error, please let an admin know!\n${error}`);
|
message.channel.send(`There was an error, please let an admin know!\n${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
makeTempChannel(message);
|
||||||
|
|
||||||
// Clear the queue
|
// Clear the queue
|
||||||
playerQueue = [];
|
playerQueue = [];
|
||||||
logger.log('info', 'Emptied queue');
|
logger.log('info', 'Emptied queue');
|
||||||
@@ -109,6 +111,31 @@ function getUserFromMention(mention) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getChannelName(username) {
|
||||||
|
return `${username}'s adventurers`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeTempChannel(message) {
|
||||||
|
const everyoneRole = message.guild.defaultRole;
|
||||||
|
let createdChannelId = '';
|
||||||
|
|
||||||
|
const channelName = getChannelName(message.author.username);
|
||||||
|
message.guild.createChannel(channelName, 'text')
|
||||||
|
.then(createdChannel => {
|
||||||
|
playerQueue.forEach(player => {
|
||||||
|
createdChannel.overwritePermissions(player.id, { VIEW_CHANNEL: true });
|
||||||
|
});
|
||||||
|
createdChannel.overwritePermissions(client.id, { VIEW_CHANNEL: true });
|
||||||
|
createdChannel.overwritePermissions(everyoneRole, { VIEW_CHANNEL: false });
|
||||||
|
|
||||||
|
createdChannelId = createdChannel.id;
|
||||||
|
})
|
||||||
|
.catch(logger.error);
|
||||||
|
|
||||||
|
// Delete the channel after 20 minutes
|
||||||
|
setTimeout(function(){ deleteChannel(createdChannelId); }, 20000);
|
||||||
|
}
|
||||||
|
|
||||||
client.on('message', function (message) {
|
client.on('message', function (message) {
|
||||||
// Ignore messages from the bot and that don't begin with the prefix
|
// Ignore messages from the bot and that don't begin with the prefix
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user