【问题标题】:Block Kick or set Limit to Kick Discord.js阻止踢或将限制设置为踢 Discord.js
【发布时间】:2019-12-22 05:03:59
【问题描述】:

你好,我不想让模组在我的服务器上做踢动作,我看到 discord.js 没有像 guildMemberAdd 一样添加 guildKickAdd 那么如何阻止踢球或设置限制踢球?

当有人禁止动作机器人扮演角色并给予他惩罚时,这是禁止阻止。

client.on("guildBanAdd", async function(guild, user) {
  const entry = await guild
    .fetchAuditLogs({ type: "MEMBER_BAN_ADD" })
    .then(audit => audit.entries.first());
  const yetkili = await guild.members.get(entry.executor.id);
  setTimeout(async () => {
    let logs = await guild.fetchAuditLogs({ type: "MEMBER_BAN_ADD" });
    if (logs.entries.first().executor.bot) return;

    guild.members
      .get(logs.entries.first().executor.id)
      .removeRoles(guild.members.get(logs.entries.first().executor.id).roles); ///TÜM ROLLERİNİ ALIR
    setTimeout(() => {
      guild.members
        .get(logs.entries.first().executor.id)
        .addRole("633026228537917460"); /// VERİLECEK CEZALI ROL İD
    }, 3000);
    const sChannel = guild.channels.find(c => c.id === "641032067840344064");
    const cıks = new Discord.RichEmbed()
      .setColor("RANDOM")
      .setDescription(
        `<@${yetkili.id}> ${user} adlı Kişiye Sağ tık ban Atıldığı için Banlayan Kişinin Yetkileri Alındı`
      )
      .setFooter("Created by Tokuchi");
    sChannel.send(cıks);
    guild.owner.send(
      `Tokuchi Affetmez † Guard | ** <@${yetkili.id}> İsimili Yetkili <@${user.id}>** Adlı Kişiyi Banladı Ve Yetkilerini Aldım.`
    );
  }, 2000);
});```

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    你需要使用guildMemberRemove事件:

    // When a member left. Maybe he left himself, but maybe he was kicked.
    client.on("guildMemberRemove", (member) => {
        // Get the last kick case of the server
        const entry = await guild
        .fetchAuditLogs({ type: "MEMBER_KICK" })
        .then(audit => audit.entries.first());
        // if there's not any kick case in this server
        if(!entry) return;
        // if the target was not the member who left
        if(entry.target.id !== member.id) return;
    
        // Else, you know the member was kicked, and you have the entry so you can do what you want
    });
    

    这是了解某人是否被踢的最好方法。

    【讨论】:

    • 是的,我是这样做的,但是当有人离开时,他会扮演邀请他的人的角色
    • link 这是我使用的命令,就像我在有人离开时使用此命令时所说的那样,机器人会扮演邀请他的人的角色
    猜你喜欢
    • 2021-08-22
    • 2020-11-18
    • 2020-10-20
    • 2021-06-01
    • 1970-01-01
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多