-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
oauth2.ts
205 lines (201 loc) · 6.32 KB
/
oauth2.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* Types extracted from https://discord.com/developers/docs/topics/oauth2
*/
import type { Snowflake } from '../../common/mod.ts';
import type { APITeam } from './teams.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-application-information-response-structure
*/
export interface APIApplication {
/**
* The id of the app
*/
id: Snowflake;
/**
* The name of the app
*/
name: string;
/**
* The icon hash of the app
*/
icon: string | null;
/**
* The description of the app
*/
description: string;
/**
* An array of rpc origin urls, if rpc is enabled
*/
rpc_origins?: string[];
/**
* When `false` only app owner can join the app's bot to guilds
*/
bot_public: boolean;
/**
* When `true` the app's bot will only join upon completion of the full oauth2 code grant flow
*/
bot_require_code_grant: boolean;
/**
* Partial user object containing info on the owner of the application
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
owner: APIUser;
/**
* If this application is a game sold on Discord, this field will be the summary field for the store page
* of its primary sku
*/
summary: string;
/**
* The base64 encoded key for the GameSDK's GetTicket
*
* See https://discord.com/developers/docs/game-sdk/applications#get-ticket
*/
verify_key: string;
/**
* The team this application belongs to
*
* See https://discord.com/developers/docs/topics/teams#data-models-team-object
*/
team: APITeam | null;
/**
* If this application is a game sold on Discord, this field will be the guild to which it has been linked
*/
guild_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
*/
primary_sku_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the URL slug that links to the store page
*/
slug?: string;
/**
* If this application is a game sold on Discord, this field will be the hash of the image on store embeds
*/
cover_image?: string;
/**
* The application's public flags
*/
flags: ApplicationFlags;
}
export enum ApplicationFlags {
ManagedEmoji = 1 << 2,
GroupDMCreate = 1 << 4,
RPCHasConnected = 1 << 11,
GatewayPresence = 1 << 12,
GatewayPresenceLimit = 1 << 13,
GatewayGuildMembers = 1 << 14,
GatewayGuildMembersLimited = 1 << 15,
VerificationPendingGuildLimit = 1 << 16,
Embedded = 1 << 17,
}
export enum OAuth2Scopes {
/**
* For oauth2 bots, this puts the bot in the user's selected guild by default
*/
Bot = 'bot',
/**
* Allows [/users/@me/connections](https://discord.com/developers/docs/resources/user#get-user-connections)
* to return linked third-party accounts
*
* See https://discord.com/developers/docs/resources/user#get-user-connections
*/
Connections = 'connections',
/**
* Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email`
*
* See https://discord.com/developers/docs/resources/user#get-current-user
*/
Email = 'email',
/**
* Allows [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) without `email`
*
* See https://discord.com/developers/docs/resources/user#get-current-user
*/
Identify = 'identify',
/**
* Allows [/users/@me/guilds](https://discord.com/developers/docs/resources/user#get-current-user-guilds)
* to return basic information about all of a user's guilds
*
* See https://discord.com/developers/docs/resources/user#get-current-user-guilds
*/
Guilds = 'guilds',
/**
* Allows [/guilds/{guild.id}/members/{user.id}](https://discord.com/developers/docs/resources/guild#add-guild-member)
* to be used for joining users to a guild
*
* See https://discord.com/developers/docs/resources/guild#add-guild-member
*/
GuildsJoin = 'guilds.join',
/**
* Allows your app to join users to a group dm
*
* See https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
GroupDMJoins = 'gdm.join',
/**
* For local rpc server api access, this allows you to read messages from all client channels
* (otherwise restricted to channels/guilds your app creates)
*/
MessagesRead = 'messages.read',
/**
* For local rpc server access, this allows you to control a user's local Discord client - whitelist only
*/
RPC = 'rpc',
/**
* For local rpc server api access, this allows you to access the API as the local user - whitelist only
*/
RPCApi = 'rpc.api',
/**
* For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only
*/
RPCNotificationsRead = 'rpc.notifications.read',
/**
* This generates a webhook that is returned in the oauth token response for authorization code grants
*/
WebhookIncoming = 'webhook.incoming',
/**
* Allows your app to upload/update builds for a user's applications - whitelist only
*/
ApplicationsBuildsUpload = 'applications.builds.upload',
/**
* Allows your app to read build data for a user's applications
*/
ApplicationsBuildsRead = 'applications.builds.read',
/**
* Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications
*/
ApplicationsStoreUpdate = 'applications.store.update',
/**
* Allows your app to read entitlements for a user's applications
*/
ApplicationsEntitlements = 'applications.entitlements',
/**
* Allows your app to know a user's friends and implicit relationships - whitelist only
*/
RelationshipsRead = 'relationships.read',
/**
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - whitelist only
*/
ActivitiesRead = 'activities.read',
/**
* Allows your app to update a user's activity - whitelist only (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
*
* See https://discord.com/developers/docs/game-sdk/activities
*/
ActivitiesWrite = 'activities.write',
/**
* Allows your app to create Slash Commands in the authorized guild
*
* See https://discord.com/developers/docs/interactions/slash-commands
*/
ApplicationsCommands = 'applications.commands',
/**
* Allows your app to update Slash Commands via this bearer token
*
* See https://discord.com/developers/docs/interactions/slash-commands
*/
ApplicationsCommandsUpdate = 'applications.commands.update',
}