K
Kord2y ago
rebok

Getting members on Guild type doesn't return same amount members as when getting memberCount from it

I tried using rest. Gettings members from guild returns only the bot itself but getting member count returns 3(the actual amount)
14 Replies
LustigerLurch
LustigerLurch2y ago
what kord api did you call in both cases?
rebok
rebokOP2y ago
I got the guild from slash command:
var Guld = KordInstance.getGuildOrNull(interaction.getChannel().data.guildId.value!!)
var Guld = KordInstance.getGuildOrNull(interaction.getChannel().data.guildId.value!!)
Then case 1
println(Guld?.memberCount)
println(Guld?.memberCount)
case 2:
println(KordInstance.rest.guild.getGuildMembers(Guld?.id!!).size)
println(KordInstance.rest.guild.getGuildMembers(Guld?.id!!).size)
and case 2 not using rest:
Guld.members.toList().size
Guld.members.toList().size
LustigerLurch
LustigerLurch2y ago
case 2.1 calls this endpoint: https://discord.com/developers/docs/resources/guild#list-guild-members - so you are probably missing the guild members intent case 2.2 uses either the cached members (which might not be all) or also calls this endpoint
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
LustigerLurch
LustigerLurch2y ago
also if you have a subtype of GuildInteraction (you can listen to the Guild prefixed interaction create event or use an is check), this can be simplified to interaction.guild / interaction.getGuild()
rebok
rebokOP2y ago
I got the intent already set up, but it still doesn't work And it's chatInputCommandInteractionEvent
LustigerLurch
LustigerLurch2y ago
in your code and the dev portal? then you can use GuildChatInputCommandInteractionCreateEvent
rebok
rebokOP2y ago
yes
LustigerLurch
LustigerLurch2y ago
hm, that's weird
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
rebok
rebokOP2y ago
I also tried It did give me the same result I recreated bot(on dev dashboard), and it looks it was some problem with intents and that fixes problem(if you use something like ExampleGuild.fetchGuild().members, using rest api for me returns only bot, also requestMembers does the same thing)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
rebok
rebokOP2y ago
it actually has
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
rebok
rebokOP2y ago
I mean i tried without fetchGuild, just accessing members, and it didn't work

Did you find this page helpful?