From 7d6e5c6cd6ff0e79fb21927ae81bd643e29a7d61 Mon Sep 17 00:00:00 2001 From: JonnyBnator Date: Wed, 20 Mar 2024 16:24:09 +0100 Subject: [PATCH] Fix Guild type in example --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9444556..2357ef2 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,19 @@ import type { DiscordProfile, PartialDiscordGuild } from "remix-auth-discord"; import { DiscordStrategy } from "remix-auth-discord"; import { sessionStorage } from "~/session.server"; +/** + * In this example we will remove the features of the guilds the user is in, + * so we have to create our own (slightly changed) type for the guilds. + * You might need to edit this in your use case. + */ +type CustomDiscordGuild = Omit; + export interface DiscordUser { id: DiscordProfile["id"]; displayName: DiscordProfile["displayName"]; avatar: DiscordProfile["__json"]["avatar"]; email: DiscordProfile["__json"]["email"]; - guilds?: Array; + guilds?: Array; accessToken: string; refreshToken: string; } @@ -84,9 +91,10 @@ const discordStrategy = new DiscordStrategy( )?.json(); /** * In this example we're only interested in guilds where the user is either the owner or has the `MANAGE_GUILD` permission (This check includes the `ADMINISTRATOR` permission) - * And not interested in the Guild Features + * And not interested in the Guild Features. + * That's why we use the earlier created CustomDiscordGuild type now. */ - const guilds: Array = userGuilds + const guilds: Array = userGuilds .filter( (g) => g.owner || (BigInt(g.permissions) & BigInt(0x20)) == BigInt(0x20),