Skip to main content

Function: canUserCreateCards()

function canUserCreateCards(
guildId,
userRoleIds,
isAdmin): boolean

Checks if a user is authorized to create roadmap cards.

A user is authorized if they are an administrator OR if they have any role that is in the authorized creator roles list. Administrators are always authorized regardless of the role configuration.

Parameters

ParameterTypeDescription
guildIdstringThe Discord guild ID
userRoleIdsstring[]Array of role IDs the user has
isAdminbooleanWhether the user is an administrator

Returns

boolean

True if the user can create cards, false otherwise

Example

const member = interaction.member;
const isAdmin = member.permissions.has(PermissionFlagsBits.Administrator);
const userRoles = member.roles.cache.map(r => r.id);

if (canUserCreateCards(guildId, userRoles, isAdmin)) {
// Allow card creation
} else {
// Deny access
}