diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9715e5d60..22f723dca 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -53,65 +53,28 @@ Examples of bad PR title: ## Types Guide -1. Discordeno Types - -- Must use camel case -- Do not allow `null` -- Each field or property must be accompanied with a reasonable JSDoc comment - just above it. -- These typings should be kept in the file with the function. -- "Discordeno types" should be accompanied at the end of the file in which the - type is used. - -Example: - -```ts -// Discordeno has utility type CamelCaseProps, where T is an interface with keys in snake case. -// It can be used to "generate" corresponding "Discordeno type" from "Discord type". -// Example: export type BanOptions = CamelCaseProps - -export interface EditMemberOptions { - /** Value to set users nickname to. Requires MANAGE_NICKNAMES permission. */ - nick?: string; - /** Array of role ids the member will have after this edit. Useful for adding/removing multiple roles in 1 API call. Requires MANAGE_ROLES permission. */ - roles?: string[]; - /** Whether the user is muted in voice channels. Requires MUTE_MEMBERS permission. */ - mute?: boolean; - /** Whether the user is deafened in voice channels. Requires DEAFEN_MEMBERS permission. */ - deaf?: boolean; - /** The id of the channel to move user to if they are connected to voice. To kick the user from their current channel, set to null. Requires MOVE_MEMBERS permission. When moving members to channels, must have permissions to both CONNECT to the channel and have the MOVE_MEMBER permission. */ - channelID?: string; -} -``` - -2. Discord Types - -- Must use snake case (or whatever discord uses. Everything here should be in - accordance with Discord API documentation) -- Each field or property must be accompanied with a reasonable JSDoc comment - just above it. -- "Discord types" must be inside of the `types` module (src/types). +- Must use snake case (according to Discord API). +- Each field or property must be accompanied with a reasonable JSDoc comment right above its type definition. - The name of the type must be prefixed with `Discord`. +- Must be placed inside of the types module (in `src/types` directory). Example: ```ts -export interface DiscordMember { - /** The user this guild member represents */ - user: UserPayload; - /** The user's guild nickname if one is set. */ - nick?: string; - /** Array of role ids that the member has */ - roles: string[]; - /** When the user joined the guild. */ - joined_at: string; - /** When the user used their nitro boost on the server. */ - premium_since?: string; - /** Whether the user is deafened in voice channels */ - deaf: boolean; - /** Whether the user is muted in voice channels */ - mute: boolean; - /** Whether the user has passed the guild's Membership Screening requirements */ - pending?: boolean; +export interface User { + id: string; + username: string; + discriminator: string; + avatar: string | null; + bot?: boolean; + system?: boolean; + mfaEnabled?: boolean; + locale?: string; + verified?: boolean; + email?: string; + flags?: number; + premiumType?: number; } + +export type DiscordUser = SnakeCaseProps; ```