提问者:小点点

discord.js:倾听踢腿


我正在构建一个服务器保护功能。 我想听听公会的消息。 我知道要听ban,但我找不到要踢的项目。 踢腿有项目吗? 如果没有,有没有一种方法可以让你听着踢腿呢?


共1个答案

匿名用户

你可以在discord.js官方维基上找到有关kicks事件的帮助。 链接:链接

事件为:GuildMemberRemove

这是https://discordjs.guide中的一个示例(单击链接可以找到此示例):

client.on('guildMemberRemove', async member => {
    const fetchedLogs = await member.guild.fetchAuditLogs({
        limit: 1,
        type: 'MEMBER_KICK',
    });
    // Since we only have 1 audit log entry in this collection, we can simply grab the first one
    const kickLog = fetchedLogs.entries.first();

    // Let's perform a sanity check here and make sure we got *something*
    if (!kickLog) return console.log(`${member.user.tag} left the guild, most likely of their own will.`);

    // We now grab the user object of the person who kicked our member
    // Let us also grab the target of this action to double check things
    const { executor, target } = kickLog;

    // And now we can update our output with a bit more information
    // We will also run a check to make sure the log we got was for the same kicked member
    if (target.id === member.id) {
        console.log(`${member.user.tag} left the guild; kicked by ${executor.tag}?`);
    } else {
        console.log(`${member.user.tag} left the guild, audit log fetch was inconclusive.`);
    }
});

这不是我的密码。 我从discordjs.guide复制粘贴了这段代码。 你需要一份事件列表吗?

在这里你可以找到名单。 (来源:https://discord.js.org/和https://discordjs.guide)