-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(Role): role tags #4628
feat(Role): role tags #4628
Conversation
There is no way to get the role of a bot from a GuildMember instance, except for the client? const infoEmbed = new MessageEmbed();
if(member.user.bot){
infoEmbed.addField('Role created for this bot', member.roles.itsRole.toString());
}
// this could simplify userinfo commands For the moment, this can be found using: const infoEmbed = new MessageEmbed();
if(member.user.bot){
infoEmbed.addField('Role created for this bot', member.roles.cache.find((r) => r.tags.botID === member.id).toString());
} Maybe I'm wrong but as a property exists to find the role of the client, it seems logical to me to have a getter to easily get the role of the other bots |
const botRole = roles.find(r => r.tags?.botID === botID); Another getter, especially if named But |
|
This API has become very convoluted, i don't think this is necessary or exactly beneficial and will trim it back with the following considerations:
|
@Androz2091 thanks for the suggestion, this is now in as I think this is now both usable as well as verbosely named. I will also add another consideration note to the bunch above regarding #botRoleFor not being called on the #botRole getter |
d1fd5e1
to
f0b6741
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
discord/discord-api-docs#1537 (comment) reply rollout is complete |
If there is any feedback from contribs/maintainers regarding the proposed API or implementation do let me know here or on discord - as you prefer and expect interaction to be necessary. could consider removing
For less getter clutter and let these be done by the user instead through |
This comment has been minimized.
This comment has been minimized.
776a375
to
258d6a5
Compare
Please describe the changes this PR makes and why it should be merged:
role data now includes tags, indicating if the role is the boost role (premium subscription in discord lingo), belongs to an integration or bot. This feature request aims to implement this new feature into discord.js while also introducing some useful getters
Changes breakdown:
Role#isMyRole*Role#isPremiumSubscriberRole*RoleManager#myRole** See pruning considerations below
The feature part dealing with integrations is only minimal and does not need to introduce new access or getters due to consideration 8.see consideration 9.Considerations
premium_subscriber
, so the camel-case version would be #premiumSubscriber, which however sounds more like a GuildMember than a Role instance, so the suffix -Role is addedReflectthein
operator along with this rather cumbersome check and assignment are used to only create the keys on the #tags object that are actually represented in the role data payload, otherwise we'd end up with some nasty undefined or null values.premium_subscriber
key is null as per API spec, transformed totrue
here for convenienceis*
orhas*
. Note: This is not equivalent to GuildMember#guild#roles#premiumSubscriberRole as it can be used to check for said role on this specific member!Implementation: Integration identifiers are more of a nieche part here and do not need new access as Integration#rolealready exists(see 9.)API pruning considerations
This API has become very convoluted, i don't think this is necessary or exactly beneficial and will trim it back with the following considerations:
Past caveats and roadblocks
🌊 upstream: requires documentation Document role tags discord/discord-api-docs#2230🚧 caveat: Proper compatibility with partials will require fix(Partials): correctly set properties as nullable #4636 to be merged, see: feat(Role): role tags #4628 (comment)fix(Partials): correctly set properties as nullable #4636 has been reverted, accordingly 066eaa0 removes the bot check to be compatible with partials✏ draft: the feature is available but undocumented, upstream documentation might yet change🚧 caveat: As of today (2020/07/12) Discord does not send thetags
field with the initial role data.The feature works as intended when used after
<Guild>.roles.fetch()
is called to fetch all roles. According to the discord developer server the feature is "partially deployed"🚧 update: Add application/integration id to managed roles discord/discord-api-docs#1537 (comment)Guild deploy is being worked on, meaning guilds will include this data on the initial payloads once done. Also meaning convenience getters as proposed here are probably the way to go and we do not need to individually fetch roles behind the scenes in order to make it work - or awkward info boxes to tell people to do so.
Status
Semantic versioning classification: