feat(lib): adding the getUserRoles function in lib

- Needed by other modules so terminated on the lib
This commit is contained in:
Raphael 2025-11-25 15:12:01 +01:00 committed by Raphaël
parent 16f2236dd9
commit d447937c1b
2 changed files with 11 additions and 9 deletions

10
src/lib/roles.ts Normal file
View file

@ -0,0 +1,10 @@
import { GuildMember, roleMention } from 'discord.js';
export function getUserRoles(target: GuildMember): string {
const roles = target.roles.cache
.filter((role) => role.id !== target.guild.id)
.sort((a, b) => b.position - a.position)
.map((role) => roleMention(role.id));
return roles.length > 0 ? roles.join(', ') : 'No role';
}