无法联系到会员 [英] Can't reach members

查看:34
本文介绍了无法联系到会员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,用于显示角色中的成员.但是,当我为具有很多成员的角色调用此命令时,它仅返回我的名字.我该如何解决?V12

this is my code for displaying members in a role. But when i call this command for a role that has a lot of members in, it only returns my name. How i can fix it? V12

let role;

if(message.mentions.roles.first() || message.guild.roles.cache.get(args[0])) {
    role    = message.mentions.roles.first() || message.guild.roles.cache.get(args[0]);
    if(!role)
        return message.reply("I can't find this role!");
} else {
    let choosenRole = args.slice(0).join(" ");
    if(!choosenRole)
        return message.reply("Please type a role name to check.");

    role = message.guild.roles.cache.find(r => r.name === choosenRole);
    if(!role)
        return message.reply("I can't find this role!");

}

    let inrole = new Discord.MessageEmbed()
    .setColor("#09ba87")
    .setAuthor(`${role.name}(${role.members.size})`)
    .setDescription(`\n・` + role.members.map(m => m.user.username + "#" + m.user.discriminator).join("\n・"))

    let m = await message.channel.send(inrole);

推荐答案

嘿,您的问题是由于Discord Api的最新网关更改,即 Guild 缓存为空,您需要启用目的是为您解决的问题-

Hey there your issue is because of recent gateway changes of the Discord Api that the Guild cache is empty , you need to enable the intents here is a fix for you -

  • 前往 Discord开发人员门户网站
  • 选择您的应用
  • bot 部分中,如果向下滚动一点,您将看到一个名为 Privileged Gateway Intents
  • 的部分.
  • 启用 SERVER MEMBERS INTENT 并重新启动bot,您会发现您的缓存不只限于少数几个!
  • Head over to Discord Developers Portal
  • Choose your application
  • Inside the bot section if you scroll a little bit down , you will see a section named Privileged Gateway Intents
  • Enable the SERVER MEMBERS INTENT and restart the bot and you will find your cache is not limited to small number!

如果仍然可行,请尝试获取所有公会成员- message.guild.members.fetch() Discord.js

If this still dosent work try fetching all guild members - message.guild.members.fetch() Learn more about intents at Discord.js

这篇关于无法联系到会员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆