当有人Boost The Server
时帮助我发送消息,例如以下代码。
伙计们,请帮助我:)
bot.on('guildMemberUpdate', (oldMember, newMember) => {
if(oldMember.roles.size < newmember.roles.size) {
const fetchedLogs = await oldMember.guild.fetchAuditLogs({
limit: 1,
type: 'MEMBER_ROLE_UPDATE',
});
const roleAddLog = fetchedLogs.entries.first();
if (!roleAddLog ) return;
const { executor, target, extra } = kickLog;
console.log(`Role ${extra.name} added to ${<@target.id>} by ${<@executor.id>}`)
}
});
答案 0 :(得分:3)
您可以检查Nitro Booster
角色是否已分配给成员:
bot.on('guildMemberUpdate', async (oldMember, newMember) => {
const hadRole = oldMember.roles.find(role => role.name === 'Nitro Booster');
const hasRole = newMember.roles.find(role => role.name === 'Nitro Booster');
if (!hadRole && hasRole) {
newMember.guild.channels.get(/* channel ID */).send('Someone boosted the server');
}
// if you want to check which members are boosted, you can check how many have the `Nitro Booster` role:
const boostedUsers = newMember.guild.members.array().filter(member => member.roles.find(role => role.name === 'Nitro Booster'));
console.log(boostedUsers.length); // how many members are boosted
});
答案 1 :(得分:2)
您可以将GuildMember#premiumSince用于不依赖角色的方法:
bot.on('guildMemberUpdate', (oldMember, newMember) => {
if (oldMember.premiumSince !== newMember.premiumSince) {
//your code here
}
});