阻止踢或将限制设置为踢Discord.js

时间:2019-12-21 20:19:12

标签: discord.js

你好,我不想让mods在服务器中执行踢动作,我发现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);
});```

1 个答案:

答案 0 :(得分:0)

您需要使用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
});

这是知道有人被踢的最好方法。