-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
base.ts
174 lines (161 loc) · 4.55 KB
/
base.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
import type { InteractionType } from './responses.ts';
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { APIRole, LocaleString } from '../../../v10.ts';
import type { APIAttachment, APIMessage, APIPartialChannel, APIThreadMetadata } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIUser } from '../user.ts';
export type PartialAPIMessageInteractionGuildMember = Pick<
APIGuildMember,
| 'roles'
| 'premium_since'
| 'pending'
| 'nick'
| 'mute'
| 'joined_at'
| 'deaf'
| 'communication_disabled_until'
| 'avatar'
>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object
*/
export interface APIMessageInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The name of the application command, including subcommands and subcommand groups
*/
name: string;
/**
* The user who invoked the interaction
*/
user: APIUser;
/**
* The guild member who invoked the interaction, only sent in MESSAGE_CREATE events
*/
member?: PartialAPIMessageInteractionGuildMember;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionGuildMember extends APIGuildMember {
permissions: Permissions;
user: APIUser;
}
// INTERACTIONS RECEIVED
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* ID of the application this interaction is for
*/
application_id: Snowflake;
/**
* The type of interaction
*/
type: Type;
/**
* The command data payload
*/
data?: Data;
/**
* The guild it was sent from
*/
guild_id?: Snowflake;
/**
* The channel it was sent from
*/
channel_id?: Snowflake;
/**
* Guild member data for the invoking user, including permissions
*
* **This is only sent when an interaction is invoked in a guild**
*/
member?: APIInteractionGuildMember;
/**
* User object for the invoking user, if invoked in a DM
*/
user?: APIUser;
/**
* A continuation token for responding to the interaction
*/
token: string;
/**
* Read-only property, always `1`
*/
version: 1;
/**
* For components, the message they were attached to
*/
message?: APIMessage;
/**
* Bitwise set of permissions the app or bot has within the channel the interaction was sent from
*/
app_permissions?: Permissions;
/**
* The selected language of the invoking user
*/
locale: LocaleString;
/**
* The guild's preferred locale, if invoked in a guild
*/
guild_locale?: LocaleString;
}
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Original,
'member' | 'guild_id'
> &
Required<Pick<Original, 'user'>>;
export type APIGuildInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Original,
'user'
> &
Required<Pick<Original, 'member' | 'guild_id'>>;
/**
* https://discord.com/developers/docs/resources/channel#channel-object
*/
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
thread_metadata?: APIThreadMetadata | null;
permissions: Permissions;
parent_id?: string | null;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
permissions: Permissions;
}
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure
*/
export interface APIInteractionDataResolved {
users?: Record<Snowflake, APIUser>;
roles?: Record<Snowflake, APIRole>;
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
attachments?: Record<Snowflake, APIAttachment>;
}
/**
* @deprecated Renamed to `APIInteractionDataResolved`
*/
export type APIChatInputApplicationCommandInteractionDataResolved = APIInteractionDataResolved;
/**
* `users` and optional `members` from APIInteractionDataResolved, for user commands and user selects
*/
export type APIUserInteractionDataResolved = Required<Pick<APIInteractionDataResolved, 'users'>> &
Pick<APIInteractionDataResolved, 'members'>;
/**
* @deprecated Renamed to `APIUserInteractionDataResolved`
*/
export type APIUserApplicationCommandInteractionDataResolved = APIUserInteractionDataResolved;