Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the request method for member,guild,role,channel and other #814

Open
moltea opened this issue Jul 13, 2021 · 4 comments
Open

Add the request method for member,guild,role,channel and other #814

moltea opened this issue Jul 13, 2021 · 4 comments
Labels
✨ feature request New feature or request

Comments

@moltea
Copy link

moltea commented Jul 13, 2021

It is necessary to add the ability to get an object by ID. I want to check if there is a member on the server, but if the member is not cached, then I cannot do this, so I need a method similar to .requestMember(id: long) that would return CompletableFuture<Optional that is , if there is such a member on the server, it will return User to me, if not, then null

@ShindouMihou
Copy link
Contributor

ShindouMihou commented Jul 13, 2021

Hello, before making an issue for stuff like this, please check the documentations or try out your IDE's autocomplete or ask in Discord where most people would most likely be able to help you faster.

To answer this issue, such method already exists under DiscordApi called getUserById which returns a CompletableFuture.

As for members, it is under Server with a similar name. All documentation links are listed below, though the member should return as an Optional since most members if not all should be cached in the current implementation (as long as you have GUILD_MEMBERS intent).

But if it is not then you can request the user from DiscordApi which will check first through the cache and requests it if it isn't cached. (Then again, both methods returns the same output which is a user).

https://docs.javacord.org/api/v/3.3.2/org/javacord/api/DiscordApi.html#getUserById-long-

https://docs.javacord.org/api/v/3.3.2/org/javacord/api/entity/server/Server.html#getMemberById-long-

@Bastian
Copy link
Member

Bastian commented Jul 13, 2021

I think the problem is, that there's no method to get a member (i.e., a user that has also role information).
We haven an open PR for this feature: #684

For other entities, I don't think that we can provide such methods. I'm not sure, whether or not Discord even offers such endpoints, but if it does, we would run into problems with related entities.
E.g. how would Role#getServer() work if we only get the role but not the server? Every entity besides members are always in the cache (for the shard that "owns" them). Javacord is not intended to be used without an active cache (except members).

@Bastian Bastian added the ✨ feature request New feature or request label Jul 13, 2021
@moltea
Copy link
Author

moltea commented Jul 13, 2021

I need Server#requestMemberById method (request) that returns CompletableFuture,
https://discord.com/developers/docs/resources/guild#get-guild-member
About Role#getServer(), you can store server id to Role object.

@RealYusufIsmail
Copy link
Contributor

This issue seems similar to #928. I will be implementing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature request New feature or request
Projects
None yet
4 participants