@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.
package/lib/sender.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DiscordBot } from './bot';
2
- import { Dict } from 'koishi';
2
+ import { Dict, Schema } from 'koishi';
3
3
  export declare type HandleExternalAsset = 'auto' | 'download' | 'direct';
4
4
  export declare type HandleMixedContent = 'auto' | 'separate' | 'attach';
5
5
  export declare namespace Sender {
@@ -23,12 +23,14 @@ export declare namespace Sender {
23
23
  export declare class Sender {
24
24
  private bot;
25
25
  private url;
26
+ static Config: Schema<Sender.Config>;
27
+ private results;
26
28
  private errors;
27
29
  private constructor();
28
- static from(bot: DiscordBot, url: string): (content: string, addition?: Dict<any>) => Promise<string>;
29
- post(data?: any, headers?: any): Promise<string>;
30
- sendEmbed(fileBuffer: ArrayBuffer, payload_json: Dict, filename: string): Promise<string>;
31
- sendContent(content: string, addition: Dict): Promise<string>;
32
- sendAsset(type: string, data: Dict<string>, addition: Dict): Promise<string>;
33
- sendMessage: (content: string, addition?: Dict) => Promise<string>;
30
+ static from(bot: DiscordBot, url: string): (content: string, addition?: Dict<any>) => Promise<string[]>;
31
+ post(data?: any, headers?: any): Promise<void>;
32
+ sendEmbed(fileBuffer: ArrayBuffer, payload_json: Dict, filename: string): Promise<void>;
33
+ sendContent(content: string, addition: Dict): Promise<void>;
34
+ sendAsset(type: string, data: Dict<string>, addition: Dict): Promise<void>;
35
+ sendMessage(content: string, addition?: Dict): Promise<string[]>;
34
36
  }
@@ -70,9 +70,15 @@ declare module './gateway' {
70
70
  }
71
71
  declare module './internal' {
72
72
  interface Internal {
73
- /** https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information */
73
+ /**
74
+ * Returns the bot's application object.
75
+ * @see https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information
76
+ */
74
77
  getCurrentBotApplicationInformation(): Promise<Application>;
75
- /** https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information */
78
+ /**
79
+ * Returns info about the current authorization. Requires authentication with a bearer token.
80
+ * @see https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information
81
+ */
76
82
  getCurrentAuthorizationInformation(): Promise<any>;
77
83
  }
78
84
  }
@@ -1,8 +1,8 @@
1
- import { Channel, Integration, snowflake, User, Webhook } from '.';
1
+ import { Channel, integer, Integration, snowflake, User, Webhook } from '.';
2
2
  /** https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure */
3
3
  export interface AuditLog {
4
4
  /** list of audit log entries */
5
- audit_log_entries: AuditLogEntry[];
5
+ audit_log_entries: AuditLog.Entry[];
6
6
  /** list of partial integration objects */
7
7
  integrations: Partial<Integration>[];
8
8
  /** list of threads found in the audit log* */
@@ -12,101 +12,117 @@ export interface AuditLog {
12
12
  /** list of webhooks found in the audit log */
13
13
  webhooks: Webhook[];
14
14
  }
15
- /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure */
16
- export interface AuditLogEntry {
17
- /** id of the affected entity (webhook, user, role, etc.) */
18
- target_id?: string;
19
- /** changes made to the target_id */
20
- changes?: AuditLogChange[];
21
- /** the user who made the changes */
22
- user_id?: snowflake;
23
- /** id of the entry */
24
- id: snowflake;
25
- /** type of action that occurred */
26
- action_type: AuditLogEvent;
27
- /** additional info for certain action types */
28
- options?: OptionalAuditEntryInfo;
29
- /** the reason for the change (0-512 characters) */
30
- reason?: string;
31
- }
32
- /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events */
33
- export declare enum AuditLogEvent {
34
- GUILD_UPDATE = 1,
35
- CHANNEL_CREATE = 10,
36
- CHANNEL_UPDATE = 11,
37
- CHANNEL_DELETE = 12,
38
- CHANNEL_OVERWRITE_CREATE = 13,
39
- CHANNEL_OVERWRITE_UPDATE = 14,
40
- CHANNEL_OVERWRITE_DELETE = 15,
41
- MEMBER_KICK = 20,
42
- MEMBER_PRUNE = 21,
43
- MEMBER_BAN_ADD = 22,
44
- MEMBER_BAN_REMOVE = 23,
45
- MEMBER_UPDATE = 24,
46
- MEMBER_ROLE_UPDATE = 25,
47
- MEMBER_MOVE = 26,
48
- MEMBER_DISCONNECT = 27,
49
- BOT_ADD = 28,
50
- ROLE_CREATE = 30,
51
- ROLE_UPDATE = 31,
52
- ROLE_DELETE = 32,
53
- INVITE_CREATE = 40,
54
- INVITE_UPDATE = 41,
55
- INVITE_DELETE = 42,
56
- WEBHOOK_CREATE = 50,
57
- WEBHOOK_UPDATE = 51,
58
- WEBHOOK_DELETE = 52,
59
- EMOJI_CREATE = 60,
60
- EMOJI_UPDATE = 61,
61
- EMOJI_DELETE = 62,
62
- MESSAGE_DELETE = 72,
63
- MESSAGE_BULK_DELETE = 73,
64
- MESSAGE_PIN = 74,
65
- MESSAGE_UNPIN = 75,
66
- INTEGRATION_CREATE = 80,
67
- INTEGRATION_UPDATE = 81,
68
- INTEGRATION_DELETE = 82,
69
- STAGE_INSTANCE_CREATE = 83,
70
- STAGE_INSTANCE_UPDATE = 84,
71
- STAGE_INSTANCE_DELETE = 85,
72
- STICKER_CREATE = 90,
73
- STICKER_UPDATE = 91,
74
- STICKER_DELETE = 92,
75
- THREAD_CREATE = 110,
76
- THREAD_UPDATE = 111,
77
- THREAD_DELETE = 112
78
- }
79
- /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info */
80
- export interface OptionalAuditEntryInfo {
81
- /** channel in which the entities were targeted */
82
- channel_id: snowflake;
83
- /** number of entities that were targeted */
84
- count: string;
85
- /** number of days after which inactive members were kicked */
86
- delete_member_days: string;
87
- /** id of the overwritten entity */
88
- id: snowflake;
89
- /** number of members removed by the prune */
90
- members_removed: string;
91
- /** id of the message that was targeted */
92
- message_id: snowflake;
93
- /** name of the role if type is "0" (not present if type is "1") */
94
- role_name: string;
95
- /** type of overwritten entity - "0" for "role" or "1" for "member" */
96
- type: string;
97
- }
98
- /** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */
99
- export interface AuditLogChange {
100
- /** new value of the key */
101
- new_value?: any;
102
- /** old value of the key */
103
- old_value?: any;
104
- /** name of audit log change key */
105
- key: string;
15
+ export declare namespace AuditLog {
16
+ /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure */
17
+ interface Entry {
18
+ /** id of the affected entity (webhook, user, role, etc.) */
19
+ target_id?: string;
20
+ /** changes made to the target_id */
21
+ changes?: Change[];
22
+ /** the user who made the changes */
23
+ user_id?: snowflake;
24
+ /** id of the entry */
25
+ id: snowflake;
26
+ /** type of action that occurred */
27
+ action_type: Type;
28
+ /** additional info for certain action types */
29
+ options?: OptionalInfo;
30
+ /** the reason for the change (0-512 characters) */
31
+ reason?: string;
32
+ }
33
+ /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events */
34
+ enum Type {
35
+ GUILD_UPDATE = 1,
36
+ CHANNEL_CREATE = 10,
37
+ CHANNEL_UPDATE = 11,
38
+ CHANNEL_DELETE = 12,
39
+ CHANNEL_OVERWRITE_CREATE = 13,
40
+ CHANNEL_OVERWRITE_UPDATE = 14,
41
+ CHANNEL_OVERWRITE_DELETE = 15,
42
+ MEMBER_KICK = 20,
43
+ MEMBER_PRUNE = 21,
44
+ MEMBER_BAN_ADD = 22,
45
+ MEMBER_BAN_REMOVE = 23,
46
+ MEMBER_UPDATE = 24,
47
+ MEMBER_ROLE_UPDATE = 25,
48
+ MEMBER_MOVE = 26,
49
+ MEMBER_DISCONNECT = 27,
50
+ BOT_ADD = 28,
51
+ ROLE_CREATE = 30,
52
+ ROLE_UPDATE = 31,
53
+ ROLE_DELETE = 32,
54
+ INVITE_CREATE = 40,
55
+ INVITE_UPDATE = 41,
56
+ INVITE_DELETE = 42,
57
+ WEBHOOK_CREATE = 50,
58
+ WEBHOOK_UPDATE = 51,
59
+ WEBHOOK_DELETE = 52,
60
+ EMOJI_CREATE = 60,
61
+ EMOJI_UPDATE = 61,
62
+ EMOJI_DELETE = 62,
63
+ MESSAGE_DELETE = 72,
64
+ MESSAGE_BULK_DELETE = 73,
65
+ MESSAGE_PIN = 74,
66
+ MESSAGE_UNPIN = 75,
67
+ INTEGRATION_CREATE = 80,
68
+ INTEGRATION_UPDATE = 81,
69
+ INTEGRATION_DELETE = 82,
70
+ STAGE_INSTANCE_CREATE = 83,
71
+ STAGE_INSTANCE_UPDATE = 84,
72
+ STAGE_INSTANCE_DELETE = 85,
73
+ STICKER_CREATE = 90,
74
+ STICKER_UPDATE = 91,
75
+ STICKER_DELETE = 92,
76
+ THREAD_CREATE = 110,
77
+ THREAD_UPDATE = 111,
78
+ THREAD_DELETE = 112
79
+ }
80
+ /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info */
81
+ interface OptionalInfo {
82
+ /** channel in which the entities were targeted */
83
+ channel_id: snowflake;
84
+ /** number of entities that were targeted */
85
+ count: string;
86
+ /** number of days after which inactive members were kicked */
87
+ delete_member_days: string;
88
+ /** id of the overwritten entity */
89
+ id: snowflake;
90
+ /** number of members removed by the prune */
91
+ members_removed: string;
92
+ /** id of the message that was targeted */
93
+ message_id: snowflake;
94
+ /** name of the role if type is "0" (not present if type is "1") */
95
+ role_name: string;
96
+ /** type of overwritten entity - "0" for "role" or "1" for "member" */
97
+ type: string;
98
+ }
99
+ /** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */
100
+ interface Change {
101
+ /** new value of the key */
102
+ new_value?: any;
103
+ /** old value of the key */
104
+ old_value?: any;
105
+ /** name of audit log change key */
106
+ key: string;
107
+ }
108
+ /** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log-query-string-params */
109
+ interface GetParams {
110
+ /** filter the log for actions made by a user */
111
+ user_id?: snowflake;
112
+ /** the type of audit log event */
113
+ action_type?: Type;
114
+ /** filter the log before a certain entry id */
115
+ before?: snowflake;
116
+ /** how many entries are returned (default 50, minimum 1, maximum 100) */
117
+ limit?: integer;
118
+ }
106
119
  }
107
120
  declare module './internal' {
108
121
  interface Internal {
109
- /** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log */
110
- getGuildAuditLog(guildId: snowflake): Promise<AuditLog>;
122
+ /**
123
+ * Returns an audit log object for the guild. Requires the 'VIEW_AUDIT_LOG' permission.
124
+ * @see https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
125
+ */
126
+ getGuildAuditLog(guildId: snowflake, params?: AuditLog.GetParams): Promise<AuditLog>;
111
127
  }
112
128
  }
@@ -0,0 +1,67 @@
1
+ import { integer, snowflake, User } from '.';
2
+ /** https://discord.com/developers/docs/resources/guild#ban-object-ban-structure */
3
+ export interface Ban {
4
+ /** the reason for the ban */
5
+ reason?: string;
6
+ /** the banned user */
7
+ user: User;
8
+ }
9
+ export declare namespace Ban {
10
+ namespace Event {
11
+ /** https://discord.com/developers/docs/topics/gateway#guild-ban-add-guild-ban-add-event-fields */
12
+ interface Add {
13
+ /** id of the guild */
14
+ guild_id: snowflake;
15
+ /** the banned user */
16
+ user: User;
17
+ }
18
+ /** https://discord.com/developers/docs/topics/gateway#guild-ban-remove-guild-ban-remove-event-fields */
19
+ interface Remove {
20
+ /** id of the guild */
21
+ guild_id: snowflake;
22
+ /** the unbanned user */
23
+ user: User;
24
+ }
25
+ }
26
+ namespace Params {
27
+ /** https://discord.com/developers/docs/resources/guild#create-guild-ban-json-params */
28
+ interface Create {
29
+ /** number of days to delete messages for (0-7) */
30
+ delete_message_days?: integer;
31
+ /** reason for the ban (deprecated) */
32
+ reason?: string;
33
+ }
34
+ }
35
+ }
36
+ declare module './gateway' {
37
+ interface GatewayEvents {
38
+ /** user was banned from a guild */
39
+ GUILD_BAN_ADD: Ban.Event.Add;
40
+ /** user was unbanned from a guild */
41
+ GUILD_BAN_REMOVE: Ban.Event.Remove;
42
+ }
43
+ }
44
+ declare module './internal' {
45
+ interface Internal {
46
+ /**
47
+ * Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission.
48
+ * @see https://discord.com/developers/docs/resources/guild#get-guild-bans
49
+ */
50
+ getGuildBans(guild_id: snowflake): Promise<Ban[]>;
51
+ /**
52
+ * Returns a ban object for the given user or a 404 not found if the ban cannot be found. Requires the BAN_MEMBERS permission.
53
+ * @see https://discord.com/developers/docs/resources/guild#get-guild-ban
54
+ */
55
+ getGuildBan(guild_id: snowflake, user_id: snowflake): Promise<Ban>;
56
+ /**
57
+ * Create a guild ban, and optionally delete previous messages sent by the banned user. Requires the BAN_MEMBERS permission. Returns a 204 empty response on success. Fires a Guild Ban Add Gateway event.
58
+ * @see https://discord.com/developers/docs/resources/guild#create-guild-ban
59
+ */
60
+ createGuildBan(guild_id: snowflake, user_id: snowflake, params: Ban.Params.Create): Promise<void>;
61
+ /**
62
+ * Remove the ban for a user. Requires the BAN_MEMBERS permissions. Returns a 204 empty response on success. Fires a Guild Ban Remove Gateway event.
63
+ * @see https://discord.com/developers/docs/resources/guild#remove-guild-ban
64
+ */
65
+ removeGuildBan(guild_id: snowflake, user_id: snowflake): Promise<void>;
66
+ }
67
+ }