Skip to content

Commit

Permalink
chore: update linked roles plugin example
Browse files Browse the repository at this point in the history
  • Loading branch information
apteryxxyz committed Oct 18, 2024
1 parent 438b92f commit 0d754ea
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions packages/carbon/src/plugins/linked-roles/LinkedRoles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,29 @@ type Tokens = {
*
* @example
* ```ts
* import { Client, LinkedRoles } from "@buape/carbon"
*
* const client = new Client({
* clientId: "12345678901234567890",
* clientSecret: "Bb7aZcvRN-BhrhY2qrUO6QzOK4SeqonG",
* publicKey: "c1a2f941ae8ce6d776f7704d0bb3d46b863e21fda491cdb2bdba6b8bc5fe7269",
* token: "MTA4NjEwNTYxMDUxMDE1NTg1Nw.GNt-U8.OSHy-g-5FlfESnu3Z9MEEMJLHiRthXajiXNwiE"
* })
*
* const allStaff = ["439223656200273932"]
*
* const linkedRoles = new LinkedRoles(client, {
* baseUrl: "https://example.com",
* metadata: [
* {
* key: "is_staff",
* name: "Verified Staff",
* description: "Whether the user is a verified staff member",
* type: ApplicationRoleConnectionMetadataType.BooleanEqual
* },
* ],
* metadataCheckers: {
* is_staff: async (userId) => {
* if (allStaff.includes(userId)) return true
* return false
* }
* }
* })
* import { createHandle, Client, ApplicationRoleConnectionMetadataType } from "@buape/carbon"
* import { LinkedRoles } from "@buape/carbon/linked-roles"
*
* const handle = createHandle((env) => {
* const client = new Client({ ... }, [ ... ])
* const linkedRoles = new LinkedRoles(client, {
* 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)
* }
* }
* })
* return [client, linkedRoles]
* })
* ```
*/
export class LinkedRoles extends Plugin {
Expand Down

0 comments on commit 0d754ea

Please sign in to comment.