mirror of
https://github.com/jcreek/denBot.git
synced 2026-07-13 10:53:45 +00:00
feat(*): Add command to delete adventure channel
This commit is contained in:
@@ -14,6 +14,7 @@ Commands:
|
|||||||
* sq - Show the queue
|
* sq - Show the queue
|
||||||
* cq - Clear the queue (admin-only, not to be shared with normal users)
|
* 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)
|
* 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
|
## Dockerize the bot
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ client.once('ready', () =>{
|
|||||||
* sq - Show the queue
|
* sq - Show the queue
|
||||||
* cq - Clear the queue
|
* cq - Clear the queue
|
||||||
* ru - Remove a tagged user from the queue
|
* ru - Remove a tagged user from the queue
|
||||||
|
* dc - Delete an adventure channel (only the captain can use this)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function generateRandomCode() {
|
function generateRandomCode() {
|
||||||
@@ -136,6 +137,11 @@ function makeTempChannel(message) {
|
|||||||
setTimeout(function(){ deleteChannel(createdChannelId); }, 20000);
|
setTimeout(function(){ deleteChannel(createdChannelId); }, 20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteChannel(channelId) {
|
||||||
|
const fetchedChannel = message.guild.channels.cache.get(channelId);
|
||||||
|
fetchedChannel.delete();
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -241,5 +247,17 @@ client.on('message', function (message) {
|
|||||||
message.channel.send(`${user.username} is not in the queue.`);
|
message.channel.send(`${user.username} is not in the queue.`);
|
||||||
logger.log('info', `${message.author.username} attempted to remove ${user.username} from queue but they weren't in it.`);
|
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.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user