feat(*): Add command to delete adventure channel

This commit is contained in:
2020-10-26 08:55:49 +00:00
parent 4ab02a6dda
commit 0c06dbd016
2 changed files with 20 additions and 1 deletions
+1
View File
@@ -14,6 +14,7 @@ Commands:
* 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)
## Dockerize the bot
+18
View File
@@ -46,6 +46,7 @@ client.once('ready', () =>{
* sq - Show the queue
* cq - Clear the queue
* ru - Remove a tagged user from the queue
* dc - Delete an adventure channel (only the captain can use this)
*/
function generateRandomCode() {
@@ -136,6 +137,11 @@ function makeTempChannel(message) {
setTimeout(function(){ deleteChannel(createdChannelId); }, 20000);
}
function deleteChannel(channelId) {
const fetchedChannel = message.guild.channels.cache.get(channelId);
fetchedChannel.delete();
}
client.on('message', function (message) {
// Ignore messages from the bot and that don't begin with the prefix
if (message.author.bot) return;
@@ -242,4 +248,16 @@ client.on('message', function (message) {
logger.log('info', `${message.author.username} attempted to remove ${user.username} from queue but they weren't in it.`);
}
}
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)
logger.log('info', `${message.author.username} deleted their adventure channel.`);
}
else {
message.channel.send(`${message.author.username} is not allowed to delete this channel.`);
logger.log('info', `${message.author.username} attempted to delete channel ${message.channel.id} but it's not their adventure channel.`);
}
}
});