discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.2k stars 3.96k forks source link

.premium property for RoleStore #3435

Closed ghost closed 4 years ago

ghost commented 5 years ago

Is your feature request related to a problem? Please describe. There's currently no way to automatically find the Nitro Booster (premium) role of a given guild.

Describe the ideal solution A .premium property for RoleStore that returns the Nitro Booster role of the guild would be very helpful.

Describe alternatives you've considered As of now, I've found no reliable alternative besides including a setting in the bot for the user to introduce the premium role manually.

SpaceEEC commented 5 years ago

I don't think there is a reliably way to get the nitro booster / premium role of a guild.

There is no field in the role structure indicating what kind of managed role it is. (Only that it is managed) Neither is there anything in the guild structure.

If Discord adds some indicator or I overlooked a solution for this, it shouldn't be an issue to implement this.

ghost commented 5 years ago

The closest I've come to accomplish it is with something like this to find a managed role that only members with .premiumSince have:

guild.roles.filter(role => role.managed).find(role => role.members.every(member => member.premiumSince))

But this is slow and fails if the guild happens to have another managed role exclusive for Nitro Boosters (although this'd be an extremely rare case).

iCrawl commented 4 years ago

But this is slow and fails if the guild happens to have another managed role exclusive for Nitro Boosters (although this'd be an extremely rare case).

Aren't all invited bots that have fixed permissions (if you don't remove them before you let them join) managed roles? I don't think thats very rare at all.