0

So, for example. If I was making a loop command for a music bot, I would use something like this in the code;

serverQueue.loop = !serverQueue.loop

msg.channel.send(`Queue Loop ${serverQueue.loop ? `**Enabled**` : `**Disabled**`}!`)

etc...

But, what exactly is

"${serverQueue.loop ? `**Enabled**` : `**Disabled**`}"

called. I know how it works I just don't know the exact name for what the "?" part is called.

With that being said, how would I use this in a different type of command for example a lock down command. I want to have the "? **Enabled** : **Disabled**" part in the code, so I don't have to do for example "!lockdown enable" or "!lockdown disable", etc. I can't figure out how to use it it my lockdown code, because it returns with the same message "Lockdown has been Enabled" every time I use the command, even though I have code to something similar as the code up above. Here is an example of my code of what I'm trying to do, and maybe it would explain it better.

var Discord = require('discord.js')

module.exports = {
    names: ['lockdown'],
    description: "Locks/Unlocks all the channels",
    execute: async function execute(client, msg, args) {

        var everyoneRole = msg.guild.roles.cache.find(r => r.name === "@everyone")

        if(!msg.member.hasPermission("ADMINISTRATOR")) {
            return msg.reply("You do not have permission to use this command!")
        } else {
            var toggle
            toggle = !toggle
            msg.channel.send(`Lockdown has been ${toggle ? `**Enabled**` : `**Disabled**`} by ${msg.author}!`)
            if(toggle) {
                msg.guild.channels.cache.forEach(channel => {
                    channel.updateOverwrite(everyoneRole.id, {
                        SEND_MESSAGES: false,
                        VIEW_CHANNEL: false,
                        READ_MESSAGE_HISTORY: false
                    })
                })
            } else {
                msg.guild.channels.cache.forEach(channel => {
                    channel.updateOverwrite(everyoneRole.id, {
                        SEND_MESSAGES: true,
                        VIEW_CHANNEL: true,
                        READ_MESSAGE_HISTORY: true
                    })
                }) 
            }
        }
    }
}

0 Answers0