💼Roles
Prototypes from RoleManager
Getting a role by ID
// discord.js
<Guild>.roles.cache.get(string);
// djs-protofy
<Guild>.roles.getById(string); // Role | undefined
Getting a role by Name
// discord.js
<Guild>.roles.cache.find(role => role.name === string);
// djs-protofy
<Guild>.roles.getByName(string | RegExp); // Role | undefined
Getting a role by Position
// discord.js
<Guild>.roles.cache.find(role => role.position === number);
// djs-protofy
<Guild>.roles.getByPosition(number); // Role | undefined
Getting a role by Raw Position
// discord.js
<Guild>.roles.cache.find(role => role.rawPosition === number);
// djs-protofy
<Guild>.roles.getByRawPosition(number); // Role | undefined
Getting a role by Unicode Emoji
// discord.js
<Guild>.roles.cache.find(role => role.unicodeEmoji === string);
// djs-protofy
<Guild>.roles.getByUnicodeEmoji(string); // Role | undefined
Filtering roles by Members
// discord.js
<Guild>.roles.cache.filter(role => role.members.hasAll(string));
// djs-protofy
<Guild>.roles.filterByMembersId(string | string[]); // Collection<string, Role>
Filtering roles by Permissions
// discord.js
<Guild>.roles.cache.filter(role => role.permissions.has(PermissionResolvable[]));
// djs-protofy
<Guild>.roles.filterByPermissions(...PermissionResolvable[]); // Collection<string, Role>
Filtering roles by Unicode Emoji
// discord.js
<Guild>.roles.cache.filter(role => role.unicodeEmoji === string);
// djs-protofy
<Guild>.roles.filterByUnicodeEmoji(string); // Collection<string, Role>
Filtering roles by Editable
// discord.js
<Guild>.roles.cache.filter(role => role.editable);
// djs-protofy
<Guild>.roles.filterEditables(); // Collection<string, Role>
Filtering roles by Uneditable
// discord.js
<Guild>.roles.cache.filter(role => !role.editable);
// djs-protofy
<Guild>.roles.filterUneditables(); // Collection<string, Role>
Filtering roles by Hoist
// discord.js
<Guild>.roles.cache.filter(role => role.hoist);
// djs-protofy
<Guild>.roles.filterHoists(); // Collection<string, Role>
Filtering roles by Non Hoist
// discord.js
<Guild>.roles.cache.filter(role => !role.hoist);
// djs-protofy
<Guild>.roles.filterNonHoists(); // Collection<string, Role>
Filtering roles by Managed
// discord.js
<Guild>.roles.cache.filter(role => role.managed);
// djs-protofy
<Guild>.roles.filterManageds(); // Collection<string, Role>
Filtering roles by Unmanaged
// discord.js
<Guild>.roles.cache.filter(role => !role.managed);
// djs-protofy
<Guild>.roles.filterUnmanageds(); // Collection<string, Role>
Filtering roles by Mentionable
// discord.js
<Guild>.roles.cache.filter(role => role.mentionable);
// djs-protofy
<Guild>.roles.filterMentionables(); // Collection<string, Role>
Filtering roles by Unmentionable
// discord.js
<Guild>.roles.cache.filter(role => !role.mentionable);
// djs-protofy
<Guild>.roles.filterUnmentionables(); // Collection<string, Role>
Searching for a role
// discord.js
<Guild>.roles.cache.find(role => {
return role.id === string
|| role.name === string;
});
// djs-protofy
<Guild>.roles.searchBy(string); // Role | undefined
// OR
<Guild>.roles.searchBy(string[]); // Collection<string, Role>
If you use an array of String, you will receive a Collection instead of Role
Last updated