Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
Check discord.js Bot Permission

Here as you see the code run at starting bot and get user invites from each server, and as you know need Administrator role but for example this bot is on 10 servers and one of these server turn off the ADMINISTRATOR role from bot and my bot got error and got Missing Access and then crash and just close I mean you must press any key

Here I want to check server perm I mean for one server and if the bot in the server didn't have role ignore it and not crash

module.exports = (client) => {
  const invites = {} // { guildId: { memberId: count } }
  const db = require("quick.db")
  const getInviteCounts = async (message,guild) => {
    return await new Promise((resolve) => {

      guild.fetchInvites().then((invites) => {

        const inviteCounter = {} // { memberId: count }

        invites.forEach((invite) => {
          const { uses, inviter } = invite
          const { username, discriminator } = inviter

          const name = `${username}#${discriminator}`

          inviteCounter[name] = (inviteCounter[name] || 0) + uses
        })

        resolve(inviteCounter)

      })

    })
  }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For discord.js v13 you need to use:

if(!message.guild.me.permissions.has("ADMINISTRATOR")) return message.reply(`I don't have ADMINISTRATOR permission`)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda