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

470
Visualizações
guild.channels.filter is not a function discord.js

I was trying to make a user presence but I am getting an error:

guild.channels.filter is not a function

My code:

const Discord = require('discord.js');
const guild = client.guilds.cache.get('847071265100791849');

const categoryChannels = guild.channels.filter(
  (channel) => channel.type === '886241068855734273'
);

categoryChannels.forEach((channel) => {
  const statuss = channel.children.size - 2;
  client.user.setPresence({
    status: 'online',
    activities: [{ name: `${statuss} Open Tickets ✉️`, type: 'WATCHING' }],
  });
});
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

guild.channels returns a GuildChannelManager so it doesn't have a filter method. You can fetch all channels that returns a collection, and then you can use filter on that:

const guild = client.guilds.cache.get('847071265100791849');
const channels = await guild.channels.fetch();
const categoryChannel = channels.filter(
  channel => channel.type === '886241068855734273'
);

That channel.type won't work though as that snowflake is not one of the ChannelTypes. You'll either need to use a valid ChannelType or use channel.id.

about 4 years ago · Juan Pablo Isaza Relatório

0

Guild#channels is a GuildChannelManager. I also see you are setting your status in a loop, which is a terrible idea, due to it being an API request. Use it outside of it and use .cache to get the Collection of channels

const categoryChannels = guild.channels.cache.filter(
  (channel) => channel.type === 'GUILD_CATEGORY' // You put an ID, not type, I fixed it for you
);

const statuss = categoryChannels.reduce((acc, channel) => channel.children.size - 2, 0)
client.user.setPresence({
    status: 'online',
    activities: [{ name: `${statuss} Open Tickets ✉️`, type: 'WATCHING' }],
  });
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