Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
Nodejs discord bot

Good afternoon, I have the code, but I can not make checks, let's say if the channel already has a discord channel with this name, the bot displays in a chat error "such a channel already exists," something like this help, please write such a check, if there are other options to address this issue, too, want to hear.

Detailed information

The result variable gets the entire list of channels that are in the discord channel.

Channels.channels[key].Name - this import gets the object from another file where it has only two values, a name and a line of code.

enter image description here

The code is provided below.

function info_channels(robot, mess, args) {
  const result = [];

  robot.channels.cache.forEach(el => {
    let new_key = el.name.replace(re, '');
    result.push(new_key);
    return result;
  });

  for(key in Channels.channels){
    mess.guild.channels.create(`${Channels.channels[key].Name} ${eval(Channels.channels[key].count_users)}`,{
      type: "voice",
      permissionOverwrites: [
        {
          id: mess.guild.roles.everyone,
          allow: [
          'VIEW_CHANNEL',
          'READ_MESSAGE_HISTORY'
          ],
          deny: [
          'CONNECT',
          'MANAGE_CHANNELS',
          'SPEAK'
          ]
        },
        {
          id: mess.guild.roles.cache.get(config.userRole),
          allow: ['VIEW_CHANNEL', 'READ_MESSAGE_HISTORY'],
          deny: ['CONNECT','MANAGE_CHANNELS','SPEAK']
        },
        {
          id: mess.guild.roles.cache.get(config.role_Rinka),
          allow: ['VIEW_CHANNEL','MANAGE_CHANNELS','READ_MESSAGE_HISTORY'],
        }
      ],
      parent: '914852886599569458',
    })
    .then(console.log(`Канал${Channels.channels[key].Name.replace(re, '')} создан!`))
    .catch(console.error);
  }

  if (Channels.channels[key].Name === result) {
    mess.channels.send('я создала');    
  } 
  else {
    mess.channel.send('я не создала');
  }

}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You could easily check if any channel name starts with any string.

// <Guild> is a placeholder for any Guild object
// <name>  is a placeholder for a channel name you're trying to check
// 
//  Note:  Channels are always cached, no matter what.

const existingChannel = <Guild>.channels.cache.find(chnl => chnl.name.startsWith(<name>);

if (existingChannel) {
    // Channel already exists
};
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda