-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.d.ts
134 lines (126 loc) · 2.89 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { EventEmitter } from "events";
export interface User {
id: string;
username: string;
discriminator: string;
avatar: string | null | undefined;
mfa_enabled?: true;
locale?: string;
verified?: boolean;
email?: string | null | undefined;
flags?: number;
premium_type?: number;
public_flags?: number;
}
export interface Member {
user?: User;
nick: string | null | undefined;
roles: string[];
joined_at: number;
premium_since?: number | null | undefined;
deaf: boolean;
mute: boolean;
}
// This is not accurate as discord sends a partial object
export interface Integration {
id: string;
name: string;
type: string;
enabled: boolean;
syncing: boolean;
role_id: string;
enable_emoticons?: boolean;
expire_behavior: 0 | 1;
expire_grace_period: number;
user?: User;
account: {
id: string;
name: string;
};
synced_at: number;
subscriber_count: number;
revoked: boolean;
application?: Application;
}
export interface Connection {
id: string;
name: string;
type: string;
revoked?: string;
integrations?: Integration[];
verified: boolean;
friend_sync: boolean;
show_activity: boolean;
visibility: 0 | 1;
}
export interface Application {
id: string;
name: string;
icon: string | null | undefined;
description: string;
summary: string;
bot?: User;
}
export interface TokenRequestResult {
access_token: string;
token_type: string;
expires_in: number;
refresh_token: string;
scope: string;
}
export interface PartialGuild {
id: string;
name: string;
icon: string | null | undefined;
owner?: boolean;
permissions?: number;
features: string[];
permissions_new?: string;
}
export default class OAuth extends EventEmitter {
constructor(opts?: {
version?: string,
clientId?: string,
redirectUri?: string,
credentials?: string,
clientSecret?: string,
requestTimeout?: number,
latencyThreshold?: number,
ratelimiterOffset?: number,
});
on(event: "debug" | "warn", listener: (message: string) => void): this;
tokenRequest(opts: {
code?: string,
scope: string[] | string,
clientId?: string,
grantType: "authorization_code" | "refresh_token",
redirectUri?: string,
refreshToken?: string,
clientSecret?: string,
}): Promise<TokenRequestResult>;
revokeToken(access_token: string, credentials?: string): Promise<string>;
getUser(access_token: string): Promise<User>;
getUserGuilds(access_token: string): Promise<PartialGuild[]>;
getUserConnections(access_token: string): Promise<Connection[]>;
addMember(opts: {
deaf?: boolean,
mute?: boolean,
roles?: string[],
nickname?: string,
userId: string,
guildId: string,
botToken: string,
accessToken: string,
}): Promise<Member>;
generateAuthUrl(opts: {
scope: string[] | string,
state?: string,
clientId?: string,
prompt?: "consent" | "none",
redirectUri?: string,
responseType?: "code" | "token",
permissions?: number,
guildId?: string,
disableGuildSelect?: boolean,
}): string;
}