johny gamer
johny gamer

Reputation: 13

How can I make a command in discord.js only usable to me?

Here's my code for the section of the command:

if (message.member.id = ("566757254100156426")) {
    message.channel.send('Obtaining ping...').then(msg => {
        const ping = msg.createdTimestamp - message.createdTimestamp;
        msg.edit(`Pong! **${ping}ms**`);
    })
} else {
    message.channel.send('You do not have the right role for this command!')
}

Upvotes: 1

Views: 147

Answers (2)

Elitezen
Elitezen

Reputation: 6710

If the id of whoever is trying to execute the command is equal to yours, execute the command. Otherwise, send an error.

if (message.member.id === '566757254100156426') {
   // command code
} else {
  // error message
}

Upvotes: 2

BoBsmil3Y
BoBsmil3Y

Reputation: 89

Use:

if (message.author.id === "566757254100156426")

In JavaScript, you have to put tree equals to test equality.

Upvotes: 0

Related Questions