Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
Prohibir a un miembro de otro gremio si está prohibido en el gremio principal

Así que lo quiero donde, si un usuario es expulsado de este gremio específico, lo prohibirá en todos los demás gremios en los que se encuentra el bot. ¿Utilizo prohibiciones de recuperación para hacer esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Antes de continuar, debe asegurarse de solicitar las siguientes intenciones al crear su bot, ya que son necesarias para lograr su objetivo: GUILDS , GUILD_BANS .

 const { Client, Intents } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_BANS] });

También debe configurar una constante llamada MAIN_GUILD_ID o algo por el estilo:

 const MAIN_GUILD_ID = 'ID';

Ahora debe escuchar el evento guildBanAdd y verificar si GuildBan.guild#id es igual al Guild#id principal (asegurándose de que el usuario haya sido baneado en el Guild principal).

 client.on('guildBanAdd', async ban => { if (ban.guild.id !== MAIN_GUILD_ID) return; });

Luego, puede recorrer todos los Guilds en los que se encuentra su bot y prohibir al usuario allí.

 client.on('guildBanAdd', async ban => { if (ban.guild.id !== MAIN_GUILD_ID) return; // Getting the guilds from the cache and filtering the main guild out. const guilds = await client.guilds.cache.filter(guild => guild.id !== MAIN_GUILD_ID); guilds.forEach(guild => { guild.members.ban(ban.user, { reason: `${ban.user.tag} was banned from ${guild.name}.` }).then(() => { console.log(`Banned ${ban.user.tag} from ${guild.name}.`); }).catch(err => { console.error(`Failed to ban ${ban.user.tag} from ${guild.name}.`, err); }); }) });

Supongo que esto es para un bot privado que está en algunos gremios; de lo contrario, si el bot está en unos pocos cientos o más gremios, su tasa de solicitud se limitará bastante rápido.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!