title: I want it to change channels name automatically with Discord.js
body: <p>Friends, I made a code and when our game server is active in my code, the bot changes the color of the message it writes to green or something, but I want it to change the name of the room, which is my code.</p>
  <p>No matter how hard I try, I can't change the name of the room he sent that message to, can you please help?</p>
  <pre><code>var TICK_N = 0;
  var MESSAGE;
  var LAST_COUNT;
  var STATUS;
  
  var STREAM_DISPATCHER = undefined;
  
  var loop_callbacks = []; // for testing whether loop is still running
  
  const log = function(level, message) {
      if (level &gt;= LOG_LEVEL) console.log(`${new Date().toLocaleString()} :${level}: ${message}`);
  };
  
  const getPlayers = function() {
      return new Promise((resolve, reject) =&gt; {
          fetchTimeout(URL_PLAYERS, FETCH_OPS, FETCH_TIMEOUT).then((res) =&gt; {
              res.json().then((players) =&gt; {
                  resolve(players);
              }).catch(reject);
          }).catch(reject);
      })
  };
  
  const getVars = function() {
      return new Promise((resolve, reject) =&gt; {
          fetchTimeout(URL_INFO, FETCH_OPS, FETCH_TIMEOUT).then((res) =&gt; {
              res.json().then((info) =&gt; {
                  resolve(info.vars);
              }).catch(reject);
          }).catch(reject);
      });
  };
  
  const bot = new Discord.Client(BOT_CONFIG);
  
  const sendOrUpdate = function(embed) {
      if (MESSAGE !== undefined) {
          MESSAGE.edit(embed).then(() =&gt; {
              log(LOG_LEVELS.DEBUG, 'Update success');
          }).catch(() =&gt; {
              log(LOG_LEVELS.ERROR, 'Update failed');
          })
      } else {
          let channel = bot.channels.get(CHANNEL_ID);
          if (channel !== undefined) {
              channel.fetchMessage(MESSAGE_ID).then((message) =&gt; {
                  MESSAGE = message;
                  message.edit(embed).then(() =&gt; {
                      log(LOG_LEVELS.SPAM, 'Update success');
                  }).catch(() =&gt; {
                      log(LOG_LEVELS.ERROR, 'Update failed');
                  });
              }).catch(() =&gt; {
                  channel.send(embed).then((message) =&gt; {
                      MESSAGE = message;
                      log(LOG_LEVELS.INFO, `Sent message (${message.id})`);
                  }).catch(console.error);
              })
          } else {
              log(LOG_LEVELS.ERROR, 'gücelleme kanalı secilmemiş');
          }
      }
  };
  
  const UpdateEmbed = function() {
      let dot = TICK_N % 2 === 0 ? 'LustRP' : 'Roleplay';
      let embed = new Discord.RichEmbed()
          //&quot;cdn.discordapp.con/atac..... sunucu logonuz&quot;
          .setAuthor(&quot;LustRP&quot;, &quot;https://cdn.discordapp.com/attachments/985288535588368434/985665669334990938/Unbenannt-.png&quot;)
          .setColor(0x2894C2)
          .setFooter(TICK_N % 2 === 0 ? '⚪ LustRP' : '⚫ LustRP')
          .setTimestamp(new Date())
      if (STATUS !== undefined) {
          embed.addField(':warning: Sunucu durumu:', `${STATUS}\n\u200b\n`);
          embed.setColor(0xff5d00)
      }
      return embed;
  };
  
  const offline = function() {
      log(LOG_LEVELS.SPAM, Array.from(arguments));
      if (LAST_COUNT !== null) log(LOG_LEVELS.INFO, `Server offline ${URL_SERVER} (${URL_PLAYERS} ${URL_INFO})`);
      let embed = UpdateEmbed()
          .setColor(0xff0000)
          .setFooter(' LustRP')
          .setDescription('\n\u200b\n **Sunucumuz şuanlık kapalıdır. En yakın zamanda aktif verilecektir.** \n\u200b\n')
          .setImage(&quot;https://cdn.discordapp.com/attachments/974298125407772702/987879840319414272/kafi1.png&quot;)
          .addField('Sunucu durumu', ':x: Kapalı', true)
          .addField('Sıra kuyruğu', '?', true)
          .addField('Aktif oyuncular', '?\n\u200b\n', true);
      sendOrUpdate(embed);
      LAST_COUNT = null;
  };
  
  const updateMessage = function() {
      getVars().then((vars) =&gt; {
          getPlayers().then((players) =&gt; {
              if (players.length !== LAST_COUNT) log(LOG_LEVELS.INFO, `${players.length} players`);
              let queue = vars['Queue'];
              let embed = UpdateEmbed()
                  .setColor(0x00ff00)
                  .setDescription('\n\u200b\n **Sunucumuza aktif verilmiştir. İyi roller dileriz.** \n\u200b\n')
                  .setFooter(' LustRP')
                  .setImage(&quot;https://cdn.discordapp.com/attachments/974298125407772702/987879840558514186/AKIF1.png&quot;)
                  .addField('Sunucu durumu', ':white_check_mark: Online', true)
                  .addField('Sıra kuyruğu', queue === 'Enabled' || queue === undefined ? '0' : queue.split(':')[1].trim(), true)
                  .addField('Aktif oyuncular', `${players.length}/${MAX_PLAYERS}\n\u200b\n`, true);
              // .addField('\u200b','\u200b\n\u200b\n',true);
              if (players.length &gt; 0) {
                  // method D
                  const fieldCount = 3;
                  const fields = new Array(fieldCount);
                  fields.fill('');
                  // for (var i=0;i&lt;players.length;i++) {
                  //   fields[i%4 &gt;= 2 ? 1 : 0] += `${players[i].name}${i % 2 === 0 ? '\u200e' : '\n\u200f'}`;
                  // }
                  fields[0] = `**Oyuncular:**\n`;
                  for (var i = 0; i &lt; players.length; i++) {
                      fields[(i + 1) % fieldCount] += `${players[i].name.substr(0,32)}\n`; // first 12 characters of players name
                  }
                  for (var i = 0; i &lt; fields.length; i++) {
                      let field = fields[i];
                      if (field.length &gt; 0) embed.addField('\u200b', field, true);
                  }
  
                  // method A
                  // let maxLen = 8;
                  // var text = '';
                  // for (var i=0;i&lt;players.length;i++) {
                  //   var eol = false;
                  //   if ((i+1) % 3 === 0) eol = true;
                  //   text += paddedFullWidth(players[i].name,eol ? players[i].name.length : maxLen);
                  //   if (eol) text += '\n';
                  // }
                  // embed.addField('Spelers',`**${text}**`,false);
  
                  // method B
                  // embed.addField('Spelers','\u200b',false);
                  // for (var player of players) {
                  //   embed.addField('\u200b',player.name,true);
                  // }
                  // for (var i=0;i&lt;3-(players.length%3);i++) {
                  //   embed.addField('\u200b','\u200b',false);
                  // }
  
                  // method C
                  // let playerNames = Array.from(players.values()).map((c) =&gt; `**${c.name}**`).join(', ');
                  // embed.addField('Spelers',playerNames,false);
              }
              sendOrUpdate(embed);
              LAST_COUNT = players.length;
          }).catch(offline);
      }).catch(offline);
      TICK_N++;
      if (TICK_N &gt;= TICK_MAX) {
          TICK_N = 0;
      }
      for (var i = 0; i &lt; loop_callbacks.length; i++) {
          let callback = loop_callbacks.pop(0);
          callback();
      }
  }; 
  </code></pre>