Skip to content
Advertisement

How can I owner lock this command in discord.js v12?

I’m trying to make this command so only I can run it, no luck so far.

JavaScript

I tried using

JavaScript

and

JavaScript

When I used the first one, the command worked but everyone was able to run it, and when I used the second one no one was able to run it at all. I don’t get any error logs nor crashes. Anyone knows the correct code?

Advertisement

Answer

As I mentioned in my comment above, the first one is definitely incorrect, as you’re converting message.author.id to a boolean by using the logical NOT operator (!). Your second attempt could work if config.ownerID was a string, but you can’t compare a string to an array.

If your config.ownerID is an array of IDs, you can use the includes() method to check if the message.author.id is included the given array:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement