Carbon
Plugins/Linked Roles/Classes

LinkedRoles

This class is the main class that is used for the linked roles feature of Carbon. It handles all the additional routes and oauth.

Example

import { Client, ApplicationRoleConnectionMetadataType } from "@buape/carbon"
import { LinkedRoles } from "@buape/carbon/linked-roles"
 
const linkedRoles = new LinkedRoles({
  metadata: [
	   {
		   key: "is_staff",
		   name: "Verified Staff",
		   description: "Whether the user is a verified staff member",
		   type: ApplicationRoleConnectionMetadataType.BooleanEqual
	   }
  ],
  metadataCheckers: {
    is_staff: async (userId) => {
      const allStaff = ["439223656200273932"]
      return allStaff.includes(userId)
    }
  }
})
 
const client = new Client({ ...  }, [ ... ], [linkedRoles])

Extends

Constructors

Constructor

new LinkedRoles(options): LinkedRoles

Parameters

ParameterType
optionsLinkedRolesOptions

Returns

LinkedRoles

Overrides

Plugin.constructor

Properties

PropertyModifierTypeDefault valueDescriptionOverrides
client?publicClientundefined--
idreadonly"linked-roles""linked-roles"An ID that identifies the plugin uniquely between all other used plugins in the ClientPlugin.id
optionspublicLinkedRolesOptionsundefined--

Methods

handleDeployRequest()

handleDeployRequest(): Promise<Response>

Handle a request to deploy the linked roles to Discord

Returns

Promise<Response>

A response


handleUserVerificationCallbackRequest()

handleUserVerificationCallbackRequest(req): Promise<Response>

Handle the verify user callback request

Parameters

ParameterTypeDescription
reqRequestThe request

Returns

Promise<Response>

A response


handleUserVerificationRequest()

handleUserVerificationRequest(): Promise<Response>

Handle the verify user request

Returns

Promise<Response>

A response


registerClient()

registerClient(client): void

Registers the client with this plugin

Parameters

ParameterTypeDescription
clientClientThe client to register

Returns

void

Overrides

Plugin.registerClient


registerRoutes()

registerRoutes(client): void

Registers the routes of this plugin with the client

Parameters

ParameterTypeDescription
clientClientThe client to register the routes with

Returns

void

Overrides

Plugin.registerRoutes

On this page