jillo-bot/src/lib/assignableRoles.ts

33 lines
758 B
TypeScript

import { Guild } from 'discord.js';
import { RoleSeperator, RoleSeperatorType, db } from './db';
export const pronouns = new Set([
'he/him',
'she/her',
'they/them',
'it/its',
'fae/faer',
'no pronouns',
'any pronouns',
'was/were',
'will/would',
]);
export function isColorRole(name: string) {
return name.startsWith('#') && name.length === 7;
}
export function isPronounRole(name: string) {
return pronouns.has(name);
}
export async function getRoleSeperator(type: RoleSeperatorType, guild: Guild) {
const seperator = await db<RoleSeperator>('roleSeperators')
.select('role')
.where('guild', guild.id)
.where('type', type)
.first();
if (seperator) return await guild.roles.fetch(seperator.role);
return null;
}