@koishijs/plugin-adapter-discord 2.0.0-rc.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ import { Channel, integer, snowflake, timestamp } from '.';
2
+ declare module './channel' {
3
+ interface Channel {
4
+ /** an approximate count of messages in a thread, stops counting at 50 */
5
+ message_count?: integer;
6
+ /** an approximate count of users in a thread, stops counting at 50 */
7
+ member_count?: integer;
8
+ /** thread-specific fields not needed by other channels */
9
+ thread_metadata?: ThreadMetadata;
10
+ /** thread member object for the current user, if they have joined the thread, only included on certain API endpoints */
11
+ member?: ThreadMember;
12
+ /** default duration for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */
13
+ default_auto_archive_duration?: integer;
14
+ }
15
+ }
16
+ /** https://discord.com/developers/docs/resources/channel#thread-member-object-thread-member-structure */
17
+ export interface ThreadMember {
18
+ /** the id of the thread */
19
+ id?: snowflake;
20
+ /** the id of the user */
21
+ user_id?: snowflake;
22
+ /** the time the current user last joined the thread */
23
+ join_timestamp: timestamp;
24
+ /** any user-thread settings, currently only used for notifications */
25
+ flags: integer;
26
+ }
27
+ /** https://discord.com/developers/docs/resources/channel#thread-metadata-object-thread-metadata-structure */
28
+ export interface ThreadMetadata {
29
+ /** whether the thread is archived */
30
+ archived: boolean;
31
+ /** duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */
32
+ auto_archive_duration: integer;
33
+ /** timestamp when the thread's archive status was last changed, used for calculating recent activity */
34
+ archive_timestamp: timestamp;
35
+ /** whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it */
36
+ locked: boolean;
37
+ /** whether non-moderators can add other non-moderators to a thread; only available on private threads */
38
+ invitable?: boolean;
39
+ }
40
+ export interface Thread extends Channel {
41
+ }
42
+ export declare namespace Thread {
43
+ /** https://discord.com/developers/docs/resources/channel#start-thread-with-message-json-params */
44
+ interface StartWithMessageParams {
45
+ /** 1-100 character channel name */
46
+ name: string;
47
+ /** duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */
48
+ auto_archive_duration?: integer;
49
+ /** amount of seconds a user has to wait before sending another message (0-21600) */
50
+ rate_limit_per_user?: integer;
51
+ }
52
+ /** https://discord.com/developers/docs/resources/channel#start-thread-without-message-json-params */
53
+ interface StartWithoutMessageParams {
54
+ /** 1-100 character channel name */
55
+ name: string;
56
+ /** duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */
57
+ auto_archive_duration?: integer;
58
+ /** the type of thread to create */
59
+ type?: integer;
60
+ /** whether non-moderators can add other non-moderators to a thread; only available when creating a private thread */
61
+ invitable?: boolean;
62
+ /** amount of seconds a user has to wait before sending another message (0-21600) */
63
+ rate_limit_per_user?: integer;
64
+ }
65
+ /** https://discord.com/developers/docs/resources/channel#list-active-threads-response-body */
66
+ interface List {
67
+ /** the active threads */
68
+ threads: Channel[];
69
+ /** a thread member object for each returned thread the current user has joined */
70
+ members: ThreadMember[];
71
+ /** whether there are potentially additional threads that could be returned on a subsequent call */
72
+ has_more: boolean;
73
+ }
74
+ /** https://discord.com/developers/docs/resources/channel#list-public-archived-threads-query-string-params */
75
+ interface ListPublicArchivedParams {
76
+ /** returns threads before this timestamp */
77
+ before?: timestamp;
78
+ /** optional maximum number of threads to return */
79
+ limit?: integer;
80
+ }
81
+ /** https://discord.com/developers/docs/resources/channel#list-private-archived-threads-query-string-params */
82
+ interface ListPrivateArchivedParams {
83
+ /** returns threads before this timestamp */
84
+ before?: timestamp;
85
+ /** optional maximum number of threads to return */
86
+ limit?: integer;
87
+ }
88
+ /** https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads-query-string-params */
89
+ interface ListJoinedPrivateArchivedParams {
90
+ /** returns threads before this id */
91
+ before?: snowflake;
92
+ /** optional maximum number of threads to return */
93
+ limit?: integer;
94
+ }
95
+ namespace Event {
96
+ /** https://discord.com/developers/docs/topics/gateway#thread-list-sync-thread-list-sync-event-fields */
97
+ interface ListSync {
98
+ /** the id of the guild */
99
+ guild_id: snowflake;
100
+ /** the parent channel ids whose threads are being synced. If omitted, then threads were synced for the entire guild. This array may contain channel_ids that have no active threads as well, so you know to clear that data. */
101
+ channel_ids?: snowflake[];
102
+ /** all active threads in the given channels that the current user can access */
103
+ threads: Channel[];
104
+ /** all thread member objects from the synced threads for the current user, indicating which threads the current user has been added to */
105
+ members: ThreadMember[];
106
+ }
107
+ interface MemberUpdate extends ThreadMember {
108
+ }
109
+ /** https://discord.com/developers/docs/topics/gateway#thread-members-update-thread-members-update-event-fields */
110
+ interface MembersUpdate {
111
+ /** the id of the thread */
112
+ id: snowflake;
113
+ /** the id of the guild */
114
+ guild_id: snowflake;
115
+ /** the approximate number of members in the thread, capped at 50 */
116
+ member_count: integer;
117
+ /** the users who were added to the thread */
118
+ added_members?: ThreadMember[];
119
+ /** the id of the users who were removed from the thread */
120
+ removed_member_ids?: snowflake[];
121
+ }
122
+ }
123
+ }
124
+ declare module './gateway' {
125
+ interface GatewayEvents {
126
+ /** sent when gaining access to a channel, contains all active threads in that channel */
127
+ THREAD_LIST_SYNC: Thread.Event.ListSync;
128
+ /** thread member for the current user was updated */
129
+ THREAD_MEMBER_UPDATE: Thread.Event.MemberUpdate;
130
+ /** some user(s) were added to or removed from a thread */
131
+ THREAD_MEMBERS_UPDATE: Thread.Event.MembersUpdate;
132
+ }
133
+ }
134
+ declare module './internal' {
135
+ interface Internal {
136
+ /**
137
+ * Returns all active threads in the guild, including public and private threads. Threads are ordered by their id, in descending order.
138
+ * @see https://discord.com/developers/docs/resources/guild#list-active-threads
139
+ */
140
+ /**
141
+ * Creates a new thread from an existing message. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters. Fires a Thread Create Gateway event.
142
+ * @see https://discord.com/developers/docs/resources/channel#start-thread-with-message
143
+ */
144
+ startThreadWithMessage(channel_id: snowflake, message_id: snowflake, params: Thread.StartWithMessageParams): Promise<Channel>;
145
+ /**
146
+ * Creates a new thread that is not connected to an existing message. The created thread defaults to a GUILD_PRIVATE_THREAD*. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters. Fires a Thread Create Gateway event.
147
+ * @see https://discord.com/developers/docs/resources/channel#start-thread-without-message
148
+ */
149
+ startThreadWithoutMessage(channel_id: snowflake, params: Thread.StartWithoutMessageParams): Promise<Channel>;
150
+ /**
151
+ * Adds the current user to a thread. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.
152
+ * @see https://discord.com/developers/docs/resources/channel#join-thread
153
+ */
154
+ joinThread(channel_id: snowflake): Promise<void>;
155
+ /**
156
+ * Adds another member to a thread. Requires the ability to send messages in the thread. Also requires the thread is not archived. Returns a 204 empty response if the member is successfully added or was already a member of the thread. Fires a Thread Members Update Gateway event.
157
+ * @see https://discord.com/developers/docs/resources/channel#add-thread-member
158
+ */
159
+ addThreadMember(channel_id: snowflake, user_id: snowflake): Promise<void>;
160
+ /**
161
+ * Removes the current user from a thread. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.
162
+ * @see https://discord.com/developers/docs/resources/channel#leave-thread
163
+ */
164
+ leaveThread(channel_id: snowflake): Promise<void>;
165
+ /**
166
+ * Removes another member from a thread. Requires the MANAGE_THREADS permission, or the creator of the thread if it is a GUILD_PRIVATE_THREAD. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.
167
+ * @see https://discord.com/developers/docs/resources/channel#remove-thread-member
168
+ */
169
+ removeThreadMember(channel_id: snowflake, user_id: snowflake): Promise<void>;
170
+ /**
171
+ * Returns a thread member object for the specified user if they are a member of the thread, returns a 404 response otherwise.
172
+ * @see https://discord.com/developers/docs/resources/channel#get-thread-member
173
+ */
174
+ getThreadMember(channel_id: snowflake, user_id: snowflake): Promise<ThreadMember>;
175
+ /**
176
+ * Returns array of thread members objects that are members of the thread.
177
+ * @see https://discord.com/developers/docs/resources/channel#list-thread-members
178
+ */
179
+ listThreadMembers(channel_id: snowflake): Promise<ThreadMember[]>;
180
+ /**
181
+ * Returns all active threads in the channel, including public and private threads. Threads are ordered by their id, in descending order.
182
+ * @see https://discord.com/developers/docs/resources/channel#list-active-threads
183
+ */
184
+ listActiveThreads(channel_id: snowflake): Promise<Thread.List>;
185
+ /**
186
+ * Returns archived threads in the channel that are public. When called on a GUILD_TEXT channel, returns threads of type GUILD_PUBLIC_THREAD. When called on a GUILD_NEWS channel returns threads of type GUILD_NEWS_THREAD. Threads are ordered by archive_timestamp, in descending order. Requires the READ_MESSAGE_HISTORY permission.
187
+ * @see https://discord.com/developers/docs/resources/channel#list-public-archived-threads
188
+ */
189
+ listPublicArchivedThreads(channel_id: snowflake, params?: Thread.ListPublicArchivedParams): Promise<Thread.List>;
190
+ /**
191
+ * Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD. Threads are ordered by archive_timestamp, in descending order. Requires both the READ_MESSAGE_HISTORY and MANAGE_THREADS permissions.
192
+ * @see https://discord.com/developers/docs/resources/channel#list-private-archived-threads
193
+ */
194
+ listPrivateArchivedThreads(channel_id: snowflake, params?: Thread.ListPrivateArchivedParams): Promise<Thread.List>;
195
+ /**
196
+ * Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined. Threads are ordered by their id, in descending order. Requires the READ_MESSAGE_HISTORY permission.
197
+ * @see https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads
198
+ */
199
+ listJoinedPrivateArchivedThreads(channel_id: snowflake, params?: Thread.ListJoinedPrivateArchivedParams): Promise<Thread.List>;
200
+ }
201
+ }
@@ -32,6 +32,17 @@ export interface User {
32
32
  /** the public flags on a user's account */
33
33
  public_flags?: integer;
34
34
  }
35
+ export declare namespace User {
36
+ namespace Params {
37
+ /** https://discord.com/developers/docs/resources/user#modify-current-user-json-params */
38
+ interface Modify {
39
+ /** user's username, if changed may cause the user's discriminator to be randomized. */
40
+ username: string;
41
+ /** if passed, modifies the user's avatar */
42
+ avatar?: string;
43
+ }
44
+ }
45
+ }
35
46
  /** https://discord.com/developers/docs/resources/user#user-object-user-flags */
36
47
  export declare enum UserFlag {
37
48
  NONE = 0,
@@ -85,21 +96,27 @@ declare module './gateway' {
85
96
  USER_UPDATE: UserUpdateEvent;
86
97
  }
87
98
  }
88
- export interface ModifyUserOptions {
89
- /** user's username, if changed may cause the user's discriminator to be randomized. */
90
- username?: string;
91
- /** if passed, modifies the user's avatar */
92
- avatar?: string;
93
- }
94
99
  declare module './internal' {
95
100
  interface Internal {
96
- /** https://discord.com/developers/docs/resources/user#get-current-user */
101
+ /**
102
+ * Returns the user object of the requester's account. For OAuth2, this requires the identify scope, which will return the object without an email, and optionally the email scope, which returns the object with an email.
103
+ * @see https://discord.com/developers/docs/resources/user#get-current-user
104
+ */
97
105
  getCurrentUser(): Promise<User>;
98
- /** https://discord.com/developers/docs/resources/user#get-user */
106
+ /**
107
+ * Returns a user object for a given user ID.
108
+ * @see https://discord.com/developers/docs/resources/user#get-user
109
+ */
99
110
  getUser(id: snowflake): Promise<User>;
100
- /** https://discord.com/developers/docs/resources/user#modify-current-user */
101
- modifyCurrentUser(options: ModifyUserOptions): Promise<User>;
102
- /** https://discord.com/developers/docs/resources/user#get-user-connections */
111
+ /**
112
+ * Modify the requester's user account settings. Returns a user object on success.
113
+ * @see https://discord.com/developers/docs/resources/user#modify-current-user
114
+ */
115
+ modifyCurrentUser(params: User.Params.Modify): Promise<User>;
116
+ /**
117
+ * Returns a list of connection objects. Requires the connections OAuth2 scope.
118
+ * @see https://discord.com/developers/docs/resources/user#get-user-connections
119
+ */
103
120
  getUserConnections(): Promise<Connection[]>;
104
121
  }
105
122
  }
@@ -28,6 +28,22 @@ export interface VoiceState {
28
28
  /** the time at which the user requested to speak */
29
29
  request_to_speak_timestamp?: timestamp;
30
30
  }
31
+ export declare namespace VoiceState {
32
+ namespace Params {
33
+ /** https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state-json-params */
34
+ interface ModifyCurrent extends Modify {
35
+ /** sets the user's request to speak */
36
+ request_to_speak_timestamp?: timestamp;
37
+ }
38
+ /** https://discord.com/developers/docs/resources/guild#modify-user-voice-state-json-params */
39
+ interface Modify {
40
+ /** the id of the channel the user is currently in */
41
+ channel_id: snowflake;
42
+ /** toggles the user's suppress state */
43
+ suppress?: boolean;
44
+ }
45
+ }
46
+ }
31
47
  /** https://discord.com/developers/docs/resources/voice#voice-region-object-voice-region-structure */
32
48
  export interface VoiceRegion {
33
49
  /** unique ID for the region */
@@ -62,7 +78,25 @@ declare module './gateway' {
62
78
  }
63
79
  declare module './internal' {
64
80
  interface Internal {
65
- /** https://discord.com/developers/docs/resources/voice#list-voice-regions */
81
+ /**
82
+ * Returns an array of voice region objects that can be used when setting a voice or stage channel's rtc_region.
83
+ * @see https://discord.com/developers/docs/resources/voice#list-voice-regions
84
+ */
66
85
  listVoiceRegions(): Promise<VoiceRegion[]>;
86
+ /**
87
+ * Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled.
88
+ * @see https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
89
+ */
90
+ getGuildVoiceRegions(guild_id: snowflake): Promise<VoiceRegion[]>;
91
+ /**
92
+ * Updates the current user's voice state.
93
+ * @see https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
94
+ */
95
+ modifyCurrentUserVoiceState(guild_id: snowflake, params: VoiceState.Params.ModifyCurrent): Promise<VoiceState>;
96
+ /**
97
+ * Updates another user's voice state.
98
+ * @see https://discord.com/developers/docs/resources/guild#modify-user-voice-state
99
+ */
100
+ modifyUserVoiceState(guild_id: snowflake, user_id: snowflake, params: VoiceState.Params.Modify): Promise<VoiceState>;
67
101
  }
68
102
  }
@@ -1,10 +1,10 @@
1
- import { Channel, Guild, integer, Message, snowflake, User } from '.';
1
+ import { AllowedMentions, Attachment, Channel, Component, Embed, Guild, Message, snowflake, User } from '.';
2
2
  /** https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-structure */
3
3
  export interface Webhook {
4
4
  /** the id of the webhook */
5
5
  id: snowflake;
6
6
  /** the type of the webhook */
7
- type: integer;
7
+ type: Webhook.Type;
8
8
  /** the guild id this webhook is for, if any */
9
9
  guild_id?: snowflake;
10
10
  /** the channel id this webhook is for, if any */
@@ -26,14 +26,84 @@ export interface Webhook {
26
26
  /** the url used for executing the webhook (returned by the webhooks OAuth2 flow) */
27
27
  url?: string;
28
28
  }
29
- /** https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types */
30
- export declare enum WebhookType {
31
- /** Incoming Webhooks can post messages to channels with a generated token */
32
- INCOMING = 1,
33
- /** Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels */
34
- CHANNEL_FOLLOWER = 2,
35
- /** Application webhooks are webhooks used with Interactions */
36
- APPLICATION = 3
29
+ export declare namespace Webhook {
30
+ /** https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types */
31
+ enum Type {
32
+ /** Incoming Webhooks can post messages to channels with a generated token */
33
+ INCOMING = 1,
34
+ /** Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels */
35
+ CHANNEL_FOLLOWER = 2,
36
+ /** Application webhooks are webhooks used with Interactions */
37
+ APPLICATION = 3
38
+ }
39
+ /** https://discord.com/developers/docs/resources/webhook#create-webhook-json-params */
40
+ interface CreateParams {
41
+ /** name of the webhook (1-80 characters) */
42
+ name: string;
43
+ /** image for the default webhook avatar */
44
+ avatar?: string;
45
+ }
46
+ /** https://discord.com/developers/docs/resources/webhook#modify-webhook-json-params */
47
+ interface ModifyParams {
48
+ /** the default name of the webhook */
49
+ name: string;
50
+ /** image for the default webhook avatar */
51
+ avatar?: string;
52
+ /** the new channel id this webhook should be moved to */
53
+ channel_id: snowflake;
54
+ }
55
+ /** https://discord.com/developers/docs/resources/webhook#execute-webhook-query-string-params */
56
+ interface ExecuteParams {
57
+ /** waits for server confirmation of message send before response, and returns the created message body (defaults to false; when false a message that is not saved does not return an error) */
58
+ wait: boolean;
59
+ /** Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived. */
60
+ thread_id: snowflake;
61
+ }
62
+ /** https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params */
63
+ interface ExecuteBody {
64
+ /** the message contents (up to 2000 characters) */
65
+ content: string;
66
+ /** override the default username of the webhook */
67
+ username: string;
68
+ /** override the default avatar of the webhook */
69
+ avatar_url: string;
70
+ /** true if this is a TTS message */
71
+ tts: boolean;
72
+ /** embedded rich content */
73
+ embeds: Embed[];
74
+ /** allowed mentions for the message */
75
+ allowed_mentions: AllowedMentions;
76
+ /** the components to include with the message */
77
+ components: Component[];
78
+ /** the contents of the file being sent */
79
+ files: any;
80
+ /** JSON encoded body of non-file params */
81
+ payload_json: string;
82
+ /** attachment objects with filename and description */
83
+ attachments: Partial<Attachment>[];
84
+ }
85
+ /** https://discord.com/developers/docs/resources/webhook#get-webhook-message-query-string-params */
86
+ interface MessageParams {
87
+ /** id of the thread the message is in */
88
+ thread_id: snowflake;
89
+ }
90
+ /** https://discord.com/developers/docs/resources/webhook#edit-webhook-message-jsonform-params */
91
+ interface MessageBody {
92
+ /** the message contents (up to 2000 characters) */
93
+ content: string;
94
+ /** embedded rich content */
95
+ embeds: Embed[];
96
+ /** allowed mentions for the message */
97
+ allowed_mentions: AllowedMentions;
98
+ /** the components to include with the message */
99
+ components: Component[];
100
+ /** the contents of the file being sent/edited */
101
+ files: any;
102
+ /** JSON encoded body of non-file params (multipart/form-data only) */
103
+ payload_json: string;
104
+ /** attached files to keep and possible descriptions for new files */
105
+ attachments: Partial<Attachment>[];
106
+ }
37
107
  }
38
108
  /** https://discord.com/developers/docs/topics/gateway#webhooks-update-webhook-update-event-fields */
39
109
  export interface WebhooksUpdateEvent {
@@ -48,39 +118,82 @@ declare module './gateway' {
48
118
  WEBHOOKS_UPDATE: WebhooksUpdateEvent;
49
119
  }
50
120
  }
51
- export interface ModifyWebhookParams {
52
- /** the default name of the webhook */
53
- name?: string;
54
- /** data image for the default webhook avatar */
55
- avatar?: string;
56
- /** the new channel id this webhook should be moved to */
57
- channel_id?: snowflake;
58
- }
59
121
  declare module './internal' {
60
122
  interface Internal {
61
- /** https://discord.com/developers/docs/resources/webhook#get-channel-webhooks */
123
+ /**
124
+ * Create a new webhook. Requires the MANAGE_WEBHOOKS permission. Returns a webhook object on success. Webhook names follow our naming restrictions that can be found in our Usernames and Nicknames documentation, with the following additional stipulations:
125
+ * @see https://discord.com/developers/docs/resources/webhook#create-webhook
126
+ */
127
+ createWebhook(channel_id: snowflake, params: Webhook.CreateParams): Promise<Webhook>;
128
+ /**
129
+ * Returns a list of channel webhook objects. Requires the MANAGE_WEBHOOKS permission.
130
+ * @see https://discord.com/developers/docs/resources/webhook#get-channel-webhooks
131
+ */
62
132
  getChannelWebhooks(channel_id: snowflake): Promise<Webhook[]>;
63
- /** https://discord.com/developers/docs/resources/webhook#get-guild-webhooks */
133
+ /**
134
+ * Returns a list of guild webhook objects. Requires the MANAGE_WEBHOOKS permission.
135
+ * @see https://discord.com/developers/docs/resources/webhook#get-guild-webhooks
136
+ */
64
137
  getGuildWebhooks(guild_id: snowflake): Promise<Webhook[]>;
65
- /** https://discord.com/developers/docs/resources/webhook#get-webhook */
138
+ /**
139
+ * Returns the new webhook object for the given id.
140
+ * @see https://discord.com/developers/docs/resources/webhook#get-webhook
141
+ */
66
142
  getWebhook(webhook_id: snowflake): Promise<Webhook>;
67
- /** https://discord.com/developers/docs/resources/webhook#get-webhook-with-token */
143
+ /**
144
+ * Same as above, except this call does not require authentication and returns no user in the webhook object.
145
+ * @see https://discord.com/developers/docs/resources/webhook#get-webhook-with-token
146
+ */
68
147
  getWebhookWithToken(webhook_id: snowflake, token: string): Promise<Webhook>;
69
- /** https://discord.com/developers/docs/resources/webhook#modify-webhook */
70
- modifyWebhook(webhook_id: snowflake, options: ModifyWebhookParams): Promise<Webhook>;
71
- /** https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token */
72
- modifyWebhookWithToken(webhook_id: snowflake, token: string, options: ModifyWebhookParams): Promise<Webhook>;
73
- /** https://discord.com/developers/docs/resources/webhook#delete-webhook */
148
+ /**
149
+ * Modify a webhook. Requires the MANAGE_WEBHOOKS permission. Returns the updated webhook object on success.
150
+ * @see https://discord.com/developers/docs/resources/webhook#modify-webhook
151
+ */
152
+ modifyWebhook(webhook_id: snowflake, params: Webhook.ModifyParams): Promise<Webhook>;
153
+ /**
154
+ * Same as above, except this call does not require authentication, does not accept a channel_id parameter in the body, and does not return a user in the webhook object.
155
+ * @see https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token
156
+ */
157
+ modifyWebhookWithToken(webhook_id: snowflake, token: string, params: Webhook.ModifyParams): Promise<Webhook>;
158
+ /**
159
+ * Delete a webhook permanently. Requires the MANAGE_WEBHOOKS permission. Returns a 204 No Content response on success.
160
+ * @see https://discord.com/developers/docs/resources/webhook#delete-webhook
161
+ */
74
162
  deleteWebhook(webhook_id: snowflake): Promise<void>;
75
- /** https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token */
76
- deleteWebhookWithToken(webhook_id: snowflake, token: string): Promise<void>;
77
- /** https://discord.com/developers/docs/resources/webhook#execute-webhook */
78
- /** https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook */
79
- /** https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook */
80
- /** https://discord.com/developers/docs/resources/webhook#get-webhook-message */
81
- getWebhookMessage(webhook_id: snowflake, token: string, message_id: snowflake): Promise<Message>;
82
- /** https://discord.com/developers/docs/resources/webhook#edit-webhook-message */
83
- /** https://discord.com/developers/docs/resources/webhook#delete-webhook-message */
84
- deleteWebhookMessage(webhook_id: snowflake, token: string, message_id: snowflake): Promise<void>;
163
+ /**
164
+ * Same as above, except this call does not require authentication.
165
+ * @see https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token
166
+ */
167
+ deleteWebhookwithToken(webhook_id: snowflake, token: string): Promise<void>;
168
+ /**
169
+ * Refer to Uploading Files for details on attachments and multipart/form-data requests.
170
+ * @see https://discord.com/developers/docs/resources/webhook#execute-webhook
171
+ */
172
+ executeWebhook(webhook_id: snowflake, token: string, body: Webhook.ExecuteBody, query: Webhook.ExecuteParams): Promise<void>;
173
+ /**
174
+ * Refer to Slack's documentation for more information. We do not support Slack's channel, icon_emoji, mrkdwn, or mrkdwn_in properties.
175
+ * @see https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook
176
+ */
177
+ executeSlackCompatibleWebhook(webhook_id: snowflake, token: string, body: null, query: Webhook.ExecuteParams): Promise<void>;
178
+ /**
179
+ * Add a new webhook to your GitHub repo (in the repo's settings), and use this endpoint as the "Payload URL." You can choose what events your Discord channel receives by choosing the "Let me select individual events" option and selecting individual events for the new webhook you're configuring.
180
+ * @see https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook
181
+ */
182
+ executeGitHubCompatibleWebhook(webhook_id: snowflake, token: string, body: null, query: Webhook.ExecuteParams): Promise<void>;
183
+ /**
184
+ * Returns a previously-sent webhook message from the same token. Returns a message object on success.
185
+ * @see https://discord.com/developers/docs/resources/webhook#get-webhook-message
186
+ */
187
+ getWebhookMessage(webhook_id: snowflake, token: string, message_id: snowflake, params: Webhook.MessageParams): Promise<Message>;
188
+ /**
189
+ * Edits a previously-sent webhook message from the same token. Returns a message object on success.
190
+ * @see https://discord.com/developers/docs/resources/webhook#edit-webhook-message
191
+ */
192
+ editWebhookMessage(webhook_id: snowflake, token: string, message_id: snowflake, body: Webhook.MessageBody, query: Webhook.MessageParams): Promise<void>;
193
+ /**
194
+ * Deletes a message that was created by the webhook. Returns a 204 No Content response on success.
195
+ * @see https://discord.com/developers/docs/resources/webhook#delete-webhook-message
196
+ */
197
+ deleteWebhookMessage(webhook_id: snowflake, token: string, message_id: snowflake, params: Webhook.MessageParams): Promise<void>;
85
198
  }
86
199
  }
package/lib/utils.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /// <reference types="koishi/lib" />
2
- import { Adapter, App, Bot, Schema, Session } from 'koishi';
2
+ import { Adapter, Bot, Schema, Session } from 'koishi';
3
+ import { Sender } from './sender';
3
4
  import { DiscordBot } from './bot';
4
5
  import * as DC from './types';
5
- export interface AdapterConfig extends Adapter.WebSocketClient.Config, App.Config.Request {
6
+ export interface AdapterConfig extends Sender.Config, Adapter.WebSocketClient.Config {
6
7
  }
7
8
  export declare const AdapterConfig: Schema<AdapterConfig>;
8
9
  export declare const adaptUser: (user: DC.User) => Bot.User;
package/lib/ws.d.ts CHANGED
@@ -1,13 +1,10 @@
1
- /// <reference path="index.d.ts" />
2
- /// <reference types="koishi/lib" />
3
- import { Adapter, Context } from 'koishi';
1
+ import { Adapter } from 'koishi';
4
2
  import { AdapterConfig } from './utils';
5
3
  import { BotConfig, DiscordBot } from './bot';
6
4
  import WebSocket from 'ws';
7
5
  export default class WebSocketClient extends Adapter.WebSocketClient<BotConfig, AdapterConfig> {
8
- static schema: import("schemastery").Schema<unknown, any>;
9
- constructor(ctx: Context, config: AdapterConfig);
10
- prepare(): WebSocket;
6
+ static schema: import("schemastery")<unknown, any>;
7
+ prepare(bot: DiscordBot): WebSocket;
11
8
  heartbeat(bot: DiscordBot): void;
12
9
  accept(bot: DiscordBot): void;
13
10
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@koishijs/plugin-adapter-discord",
3
3
  "description": "Discord adapter for Koishi",
4
- "version": "2.0.0-rc.0",
4
+ "version": "2.0.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -25,20 +25,22 @@
25
25
  "bot",
26
26
  "discord",
27
27
  "chatbot",
28
- "koishi"
28
+ "koishi",
29
+ "impl:adapter"
29
30
  ],
30
31
  "peerDependencies": {
31
- "koishi": "^4.0.0-rc.0"
32
+ "koishi": "^4.2.0"
32
33
  },
33
34
  "devDependencies": {
34
- "@koishijs/plugin-mock": "^1.0.0-rc.0",
35
+ "@koishijs/plugin-mock": "^1.0.2",
35
36
  "@types/es-aggregate-error": "^1.0.2",
36
- "@types/ws": "^7.4.7"
37
+ "@types/ws": "^8.2.2",
38
+ "axios": "^0.24.0"
37
39
  },
38
40
  "dependencies": {
39
- "es-aggregate-error": "^1.0.5",
41
+ "es-aggregate-error": "^1.0.7",
40
42
  "file-type": "^16.5.3",
41
43
  "form-data": "^4.0.0",
42
- "ws": "^8.2.1"
44
+ "ws": "^8.4.2"
43
45
  }
44
46
  }