title: discord js problem: I have a horse race command and Im trying to make it so only people with certain permissions can call the command
body: <p>I dont even know where to start adding the perms. I have tried so many options and a syntax error comes back every time. The command works perfectly. I just want it limited to who can use it like adminstrator or manage_permissions. any advice on where to start or what to do would greatly be appreciated. I really am at a loss on what to do.</p>
  <pre><code>const status = require('./../util/status');
  
  function startRace(message, args) {
      const trackLength = 50;
      const initialHorseDistance = 100;
      const numberOfHorses = 6;
      const horseNames = [&quot;Athemir&quot;, &quot;Rildonis&quot;, &quot;Hyrget&quot;, &quot;Maldonar&quot;, &quot;Zael&quot;, &quot;Getha&quot;];
  
      status.racing.initalise(horseNames);
  
      message.channel.send(&quot;Our participants are:\n&quot; + horseNames.map((horseName, i) =&gt; {return `${i + 1}: ${horseName}`}).join('\n') );
  
      let horseDistances = Array(numberOfHorses).fill(initialHorseDistance);
      raceTrack = renderRaceTrack(horseDistances, trackLength, initialHorseDistance);
  
      const bettingReactions = [&quot;\u0030\u20E3&quot;, &quot;\u0031\u20E3&quot;, &quot;\u0032\u20E3&quot;, &quot;\u0033\u20E3&quot;, &quot;\u0034\u20E3&quot;, &quot;\u0035\u20E3&quot;, &quot;\u0036\u20E3&quot;, &quot;\u0037\u20E3&quot;, &quot;\u0038\u20E3&quot;, &quot;\u0039\u20E3&quot;];
  
      message.channel.send(&quot;Bettings open for 10 minutes, place bets now.&quot;).then(
          async message =&gt; {
              // const emoji = message.guild.emojis.find('name', 'one');
              await message.react(bettingReactions[1]);
              await message.react(bettingReactions[2]);
              await message.react(bettingReactions[3]);
              await message.react(bettingReactions[4]);
              await message.react(bettingReactions[5]);
              await message.react(bettingReactions[6]);
  
              // bettingReactions.forEach(async reaction =&gt; {await message.react(reaction)} );
          }
      ).then(() =&gt; {
          const filter = (receivedReaction) =&gt; bettingReactions.includes(receivedReaction);
          message.awaitReactions(filter, { time: 600000 })
              .then(collected =&gt; {
                  console.log(collected[0]);
              })
              .then(()=&gt; {
                  message.channel.send(&quot;Bets received, starting race.&quot;);
                  message.channel.send(raceTrack).then(message =&gt; { createNextFrame(message, horseDistances, trackLength, initialHorseDistance, 0) });
              })
      });
  }
  
  function createNextFrame(message, horseDistances, trackLength, initialHorseDistance, n) {
      let winners = [];
      horseDistances.forEach((length, horse_index) =&gt; {
          length = length - Math.floor(Math.random() * 3 + 1);
          horseDistances[horse_index] = length;
          if (length &lt;= 0) winners.push(horse_index);
      });
      console.log(n);
      console.log(horseDistances);
      if (winners.length &gt; 0) {
          message.edit(renderRaceTrack(horseDistances, trackLength, initialHorseDistance));
          return declareWinner(message, winners);
      }
  
      message.edit(renderRaceTrack(horseDistances, trackLength, initialHorseDistance)).then(message =&gt; {
          setTimeout(() =&gt; {
              createNextFrame(message, horseDistances, trackLength, initialHorseDistance, n + 1);
          }, 1000);
      })
  }
  
  function declareWinner(message, winners) {
      console.log(&quot;Winner declared!&quot;)
      if (winners.length === 1)
          message.channel.send(`Horse ${winners[0]+1} has WON!`);
      else
          message.channel.send(`There has been a draw between horses ${winners[0]+1} and ${winners[0]+1}`);
  }
  
  function renderRaceTrack(horseDistances, trackLength, initialHorseDistance) {
      const horse = '&lt;:centaurracer:874074443184500847&gt;';
      const finish = ':checkered_flag:';
      const trackSeperator = '-';
      const bar = '|';
      const lane = '`' + trackSeperator.repeat(trackLength) + '`' + '\n';
      let raceTrack = lane;
      for (i = 0; i &lt; horseDistances.length; i++) {
          currentHorseDistance = horseDistances[i] &lt; 0 ? 0 : horseDistances[i];
          raceTrack = raceTrack + finish + bar + ' '.repeat(currentHorseDistance) + horse + ' '.repeat(initialHorseDistance - currentHorseDistance) + bar + ' ' + bar + ' ' + (i + 1) + '\n' + lane;
      }
      return raceTrack;
  
  }
  
  module.exports = {
      name: 'horse',
      description: 'Starts a race, with default number of horses, and default length unless otherwise specified.',
      args: 'false',
      execute: startRace
      }
  </code></pre>
  <p>This was my latest try</p>
  <pre><code>client.on(&quot;message&quot;, (message) =&gt; {
    if (message.content.startsWith(&quot;^horse&quot;)) {
        if (!message.member.permissions.has(&quot;ADMINISTRATOR&quot;)) return; 
  </code></pre>