types: add user types (#700)

* types: add user types

* Add CreateGroupDM
This commit is contained in:
ayntee
2021-03-28 20:26:07 +04:00
committed by GitHub
parent 89e4b1eacd
commit 3f40aeb75f
8 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { SnakeCaseProps } from "../util.ts";
import { DiscordVisibilityTypes } from "./visibility_types.ts";
export interface Connection {
/** id of the connection account */
id: string;
/** The username of the connection account */
name: string;
/** The service of the connection (twitch, youtube) */
type: string;
/** Whether the connection is revoked */
revoked?: boolean;
/** An array of partial server integrations */
integrations?: Integration[];
/** Whether the connection is verified */
verified: boolean;
/** Whether friend sync is enabled for this connection */
friendSync: boolean;
/** Whether activities related to this connection will be shown in presence updates */
showActivity: boolean;
/** Visibility of this connection */
visibility: DiscordVisibilityTypes;
}
/** https://discord.com/developers/docs/resources/user#connection-objecthttps://discord.com/developers/docs/resources/user#user-object-premium-types */
export type DiscordConnection = SnakeCaseProps<Connection>;

View File

@@ -0,0 +1,9 @@
import { SnakeCaseProps } from "../util.ts";
export interface CreateDM {
/** The recipient to open a DM channel with */
recipientId: string;
}
/** https://discord.com/developers/docs/resources/user#create-dm */
export type DiscordCreateDM = SnakeCaseProps<CreateDM>;

View File

@@ -0,0 +1,11 @@
import { SnakeCaseProps } from "../util.ts";
export interface CreateGroupDM {
/** Access tokens of users that have granted your app the `gdm.join` scope */
accessTokens: string[];
/** A dictionary of user ids to their respective nicknames */
nicks: Record<string, string>;
}
/** https://discord.com/developers/docs/resources/user#create-group-dm */
export type DiscordCreateGroupDM = SnakeCaseProps<CreateGroupDM>;

View File

@@ -0,0 +1,9 @@
export interface ModifyCurrentUser {
/** User's username, if changed may cause the user's discriminator to be randomized. */
username?: string;
/** If passed, modifies the user's avatar */
avatar?: string;
}
/** https://discord.com/developers/docs/resources/user#modify-current-user */
export type DiscordModifyCurrentUser = ModifyCurrentUser;

View File

@@ -0,0 +1,6 @@
/** https://discord.com/developers/docs/resources/user#user-object-premium-types */
export enum DiscordPremiumTypes {
None,
NitroClassic,
Nitro,
}

35
src/types/users/user.ts Normal file
View File

@@ -0,0 +1,35 @@
import { SnakeCaseProps } from "../util.ts";
import { DiscordPremiumTypes } from "./premium_types.ts";
import { DiscordUserFlags } from "./user_flags.ts";
export interface User {
/** The user's id */
id: string;
/** The user's username, not unique across the platform */
username: string;
/** The user's 4-digit discord-tag */
discriminator: string;
/** The user's avatar hash */
avatar: string | null;
/** Whether the user belongs to an OAuth2 application */
bot?: boolean;
/** Whether the user is an Official Discord System user (part of the urgent message system) */
system?: boolean;
/** Whether the user has two factor enabled on their account */
mfaEnabled?: boolean;
/** The user's chosen language option */
locale?: string;
/** Whether the email on this account has been verified */
verified?: boolean;
/** The user's email */
email?: string | null;
/** The flags on a user's account */
flags?: DiscordUserFlags;
/** The type of Nitro subscription on a user's account */
premiumType?: DiscordPremiumTypes;
/** The public flags on a user's account */
publicFlags?: DiscordUserFlags;
}
/** https://discord.com/developers/docs/resources/user#user-object */
export type DiscordUser = SnakeCaseProps<User>;

View File

@@ -0,0 +1,17 @@
/** https://discord.com/developers/docs/resources/user#user-object-user-flags */
export enum DiscordUserFlags {
None,
DiscordEmployee = 1 << 0,
ParteneredServerOwner = 1 << 1,
HypeSquadEvents = 1 << 2,
BugHunterLevel1 = 1 << 3,
HouseBravery = 1 << 6,
HouseBrilliance = 1 << 7,
HouseBalance = 1 << 8,
EarlySupporter = 1 << 9,
TeamUser = 1 << 10,
System = 1 << 12,
BugHunterLevel2 = 1 << 14,
VerifiedBot = 1 << 16,
EarlyVerifiedBotDeveloper = 1 << 17,
}

View File

@@ -0,0 +1,7 @@
/** https://discord.com/developers/docs/resources/user#connection-object-visibility-types */
export enum DiscordVisibilityTypes {
/** Invisible to everyone except the user themselves */
None,
/** Visible to everyone */
Everyone,
}