@indy-center/indy-larry-worker 1.0.0 → 1.2.0
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/dist/api.d.ts +202 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ export type AllowedMentions = {
|
|
|
8
8
|
/** Role IDs that may ping (not with `parse: ['roles']`). */
|
|
9
9
|
roles?: string[];
|
|
10
10
|
};
|
|
11
|
+
/** A button that opens a web address. */
|
|
12
|
+
export type LinkButton = {
|
|
13
|
+
/** Up to 80 characters. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** An http(s) address, up to 512 characters. */
|
|
16
|
+
url: string;
|
|
17
|
+
};
|
|
11
18
|
/** A message to send as Larry. At least one of `content` or `embeds` is required. */
|
|
12
19
|
export type Message = {
|
|
13
20
|
/** Up to 2000 characters. Mention a user with `<@userId>`, a role with `<@&roleId>`. */
|
|
@@ -20,6 +27,12 @@ export type Message = {
|
|
|
20
27
|
* ping more, or `{ parse: [] }` to ping nobody.
|
|
21
28
|
*/
|
|
22
29
|
allowedMentions?: AllowedMentions;
|
|
30
|
+
/**
|
|
31
|
+
* Up to 5 buttons under the message, each opening a web address. Larry offers no buttons that do
|
|
32
|
+
* something when pressed. On editMessage()/enqueueEdit(), leave it out to keep the buttons the message
|
|
33
|
+
* has, or pass `[]` to remove them.
|
|
34
|
+
*/
|
|
35
|
+
buttons?: LinkButton[];
|
|
23
36
|
};
|
|
24
37
|
/** A message to a channel. */
|
|
25
38
|
export type ChannelSend = Message & {
|
|
@@ -29,18 +42,159 @@ export type ChannelSend = Message & {
|
|
|
29
42
|
*/
|
|
30
43
|
channel: string;
|
|
31
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* A change to a message Larry posted in a channel from `SEND_CHANNELS`. What is given replaces what the
|
|
47
|
+
* message had; `content` or `embeds` left out stays as it was. An edit pings nobody.
|
|
48
|
+
*/
|
|
49
|
+
export type ChannelEdit = ChannelSend & {
|
|
50
|
+
/** The message's ID, as send() returned it. */
|
|
51
|
+
messageId: string;
|
|
52
|
+
};
|
|
53
|
+
/** A message Larry posted in a channel from `SEND_CHANNELS`, to delete. */
|
|
54
|
+
export type MessageRef = {
|
|
55
|
+
/** The channel name it was sent to, as in ChannelSend. */
|
|
56
|
+
channel: string;
|
|
57
|
+
/** The message's ID, as send() returned it. */
|
|
58
|
+
messageId: string;
|
|
59
|
+
};
|
|
32
60
|
/** A private message to a user. */
|
|
33
61
|
export type DirectSend = Message & {
|
|
34
62
|
/** The user's Discord ID. They must share a server with Larry and allow DMs from it. */
|
|
35
63
|
userId: string;
|
|
36
64
|
};
|
|
65
|
+
/** A message to a channel by ID. The channel must sit under a category in Larry's `CHANNEL_CATEGORIES`. */
|
|
66
|
+
export type ChannelIdSend = Message & {
|
|
67
|
+
/** A channel ID, e.g. one syncChannels() returned. */
|
|
68
|
+
channelId: string;
|
|
69
|
+
};
|
|
70
|
+
/** One role and who should hold it. */
|
|
71
|
+
export type RoleSync = {
|
|
72
|
+
/** The caller's own name for this entry, echoed back in the result. */
|
|
73
|
+
key: string;
|
|
74
|
+
/** Found by `id` when given and still there, otherwise by exact `name`; created (with no permissions) if neither finds one. */
|
|
75
|
+
id?: string | null;
|
|
76
|
+
name: string;
|
|
77
|
+
/**
|
|
78
|
+
* True: a role found by `id` whose name has drifted from `name` is renamed to it. Leave it out and
|
|
79
|
+
* Larry never renames a role.
|
|
80
|
+
*/
|
|
81
|
+
rename?: boolean;
|
|
82
|
+
/** Discord user IDs who should hold the role. Someone not in the server is reported and can be tried again later. */
|
|
83
|
+
members: string[];
|
|
84
|
+
/**
|
|
85
|
+
* True: **everyone not listed loses the role**, however they got it. False: Larry only adds, and
|
|
86
|
+
* never takes the role from anyone. Required, because one of those is destructive.
|
|
87
|
+
*/
|
|
88
|
+
exclusive: boolean;
|
|
89
|
+
};
|
|
90
|
+
export type RolesSync = {
|
|
91
|
+
roles: RoleSync[];
|
|
92
|
+
/** Work out and report what would change, and change nothing. */
|
|
93
|
+
dryRun?: boolean;
|
|
94
|
+
};
|
|
95
|
+
export type RoleSyncResult = {
|
|
96
|
+
key: string;
|
|
97
|
+
/** Null only when a dry run would create it, or the entry failed. */
|
|
98
|
+
roleId: string | null;
|
|
99
|
+
role: 'found' | 'created' | 'would-create';
|
|
100
|
+
/** The name it had before Larry renamed it (or would, in a dry run). */
|
|
101
|
+
renamedFrom?: string;
|
|
102
|
+
/** User IDs given the role (or who would be, in a dry run). */
|
|
103
|
+
added: string[];
|
|
104
|
+
/** User IDs the role was taken from (or would be). Always empty unless `exclusive`. */
|
|
105
|
+
removed: string[];
|
|
106
|
+
/** Wanted members Discord does not have in the server. */
|
|
107
|
+
notInServer: string[];
|
|
108
|
+
/** Why this role could not be synced. The others are unaffected. */
|
|
109
|
+
error?: string;
|
|
110
|
+
};
|
|
111
|
+
export type RolesResult = {
|
|
112
|
+
dryRun: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* False when Larry could not list the server's members, which needs the Server Members intent
|
|
115
|
+
* switched on for the bot. Roles are still added, but **nobody is removed**, and `notInServer` is
|
|
116
|
+
* only learned by trying.
|
|
117
|
+
*/
|
|
118
|
+
canSeeMembers: boolean;
|
|
119
|
+
roles: RoleSyncResult[];
|
|
120
|
+
};
|
|
121
|
+
/** One private text channel Larry should find or create. */
|
|
122
|
+
export type ManagedChannel = {
|
|
123
|
+
/** The caller's own name for this entry, echoed back in the result. */
|
|
124
|
+
key: string;
|
|
125
|
+
/** A category name from Larry's `CHANNEL_CATEGORIES` setting, e.g. `'training'`. Any other name is rejected. */
|
|
126
|
+
category: string;
|
|
127
|
+
/**
|
|
128
|
+
* Found by `id` when given and still in the category, otherwise by `name` there; created if neither
|
|
129
|
+
* finds one. The name is lowercased and hyphenated the way Discord does it.
|
|
130
|
+
*/
|
|
131
|
+
id?: string | null;
|
|
132
|
+
name: string;
|
|
133
|
+
/**
|
|
134
|
+
* True: a channel found by `id` whose name has drifted from `name` is renamed to it. Nothing else
|
|
135
|
+
* about a found channel is ever changed. Leave it out and Larry never renames a channel.
|
|
136
|
+
*/
|
|
137
|
+
rename?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Role IDs that can see and post in the channel **when Larry creates it**; nobody else can. A channel
|
|
140
|
+
* Larry finds keeps its permissions exactly as they are.
|
|
141
|
+
*/
|
|
142
|
+
visibleTo: string[];
|
|
143
|
+
};
|
|
144
|
+
export type ChannelsSync = {
|
|
145
|
+
channels: ManagedChannel[];
|
|
146
|
+
/** Work out and report what would change, and change nothing. */
|
|
147
|
+
dryRun?: boolean;
|
|
148
|
+
};
|
|
149
|
+
export type ChannelSyncResult = {
|
|
150
|
+
key: string;
|
|
151
|
+
/** Null only when a dry run would create it, or the entry failed. */
|
|
152
|
+
channelId: string | null;
|
|
153
|
+
/** The channel's name as Discord has it, or would. */
|
|
154
|
+
channelName: string;
|
|
155
|
+
channel: 'found' | 'created' | 'would-create';
|
|
156
|
+
/** The name it had before Larry renamed it (or would, in a dry run). */
|
|
157
|
+
renamedFrom?: string;
|
|
158
|
+
/** Why this channel could not be synced. The others are unaffected. */
|
|
159
|
+
error?: string;
|
|
160
|
+
};
|
|
161
|
+
export type ChannelsResult = {
|
|
162
|
+
dryRun: boolean;
|
|
163
|
+
channels: ChannelSyncResult[];
|
|
164
|
+
};
|
|
165
|
+
/** One person and one role: whether they should hold it. */
|
|
166
|
+
export type MemberRole = {
|
|
167
|
+
/** The person's Discord user ID. */
|
|
168
|
+
userId: string;
|
|
169
|
+
roleId: string;
|
|
170
|
+
/** True to give them the role, false to take it away. Saying it again changes nothing. */
|
|
171
|
+
has: boolean;
|
|
172
|
+
};
|
|
173
|
+
/** What happened to one role or channel a caller asked Larry to delete. */
|
|
174
|
+
export type Deletion = {
|
|
175
|
+
id: string;
|
|
176
|
+
/** `gone`: Discord no longer had it, which is the state the caller wanted. */
|
|
177
|
+
outcome: 'deleted' | 'would-delete' | 'gone';
|
|
178
|
+
/** Why it was not deleted. The others are unaffected. */
|
|
179
|
+
error?: string;
|
|
180
|
+
};
|
|
181
|
+
export type DeleteRequest = {
|
|
182
|
+
/** Role IDs for deleteRoles(), channel IDs for deleteChannels(). */
|
|
183
|
+
ids: string[];
|
|
184
|
+
/** Report what would be deleted, and delete nothing. */
|
|
185
|
+
dryRun?: boolean;
|
|
186
|
+
};
|
|
187
|
+
export type DeleteResult = {
|
|
188
|
+
dryRun: boolean;
|
|
189
|
+
deleted: Deletion[];
|
|
190
|
+
};
|
|
37
191
|
/** Where a message was posted. */
|
|
38
192
|
export type Sent = {
|
|
39
193
|
channelId: string;
|
|
40
194
|
messageId: string;
|
|
41
195
|
};
|
|
42
196
|
/**
|
|
43
|
-
* Larry's RPC surface, version 1.
|
|
197
|
+
* Larry's RPC surface, version 1.2.0. Every method checks the message first and throws for an unknown
|
|
44
198
|
* channel, a bad user ID, an empty message or one over Discord's limits.
|
|
45
199
|
*/
|
|
46
200
|
export interface LarryRpc extends Rpc.WorkerEntrypointBranded {
|
|
@@ -55,6 +209,53 @@ export interface LarryRpc extends Rpc.WorkerEntrypointBranded {
|
|
|
55
209
|
enqueue(request: ChannelSend): Promise<void>;
|
|
56
210
|
/** Queue a DM, like enqueue(). */
|
|
57
211
|
enqueueDirect(request: DirectSend): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Change a message Larry posted, now, and return it. Throws if Discord refuses, including when the
|
|
214
|
+
* message has been deleted or was not Larry's.
|
|
215
|
+
*/
|
|
216
|
+
editMessage(request: ChannelEdit): Promise<Sent>;
|
|
217
|
+
/** Queue the same change, like enqueue(). An edit to a message that has since been deleted is dropped. */
|
|
218
|
+
enqueueEdit(request: ChannelEdit): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Delete a message Larry posted, now. **Cannot be undone.** A message that is already gone counts as
|
|
221
|
+
* deleted. Throws if Discord refuses, e.g. for someone else's message without Manage Messages.
|
|
222
|
+
*/
|
|
223
|
+
deleteMessage(request: MessageRef): Promise<void>;
|
|
224
|
+
/** Queue the same deletion and return once it's queued. Delivery retries rate limits and Discord outages. */
|
|
225
|
+
enqueueDelete(request: MessageRef): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Make each role's membership match what is asked for, and report what changed. One role failing
|
|
228
|
+
* does not stop the rest. Refuses roles that carry moderation permissions. Throws if `GUILD_ID` isn't set.
|
|
229
|
+
*/
|
|
230
|
+
syncRoles(request: RolesSync): Promise<RolesResult>;
|
|
231
|
+
/** Find each channel or create it under its category, and report which. Never changes a channel it finds. */
|
|
232
|
+
syncChannels(request: ChannelsSync): Promise<ChannelsResult>;
|
|
233
|
+
/**
|
|
234
|
+
* Give one person a role, or take it away, now. For a single change made on the spot (a button
|
|
235
|
+
* press); to keep a whole role's membership in step, use syncRoles(). Under the same guard as
|
|
236
|
+
* syncRoles(). Throws if Discord refuses, including when the person isn't in the server.
|
|
237
|
+
*/
|
|
238
|
+
setMemberRole(request: MemberRole): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Queue the same change and return once it's queued. Delivery retries rate limits and Discord
|
|
241
|
+
* outages, so the caller needs no retry of its own. The role is checked before it is queued; a
|
|
242
|
+
* change for someone not in the server is logged and dropped.
|
|
243
|
+
*/
|
|
244
|
+
enqueueMemberRole(request: MemberRole): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* Delete roles outright, for everyone who holds them. **Cannot be undone.** Under the same guard as
|
|
247
|
+
* syncRoles(): Larry refuses a role with moderation permissions, a bot's role and @everyone.
|
|
248
|
+
*/
|
|
249
|
+
deleteRoles(request: DeleteRequest): Promise<DeleteResult>;
|
|
250
|
+
/**
|
|
251
|
+
* Delete channels and every message in them. **Cannot be undone.** Only text channels under a
|
|
252
|
+
* category in `CHANNEL_CATEGORIES`; anything else is refused.
|
|
253
|
+
*/
|
|
254
|
+
deleteChannels(request: DeleteRequest): Promise<DeleteResult>;
|
|
255
|
+
/** Post now to a channel by ID. Throws unless it is under a category in `CHANNEL_CATEGORIES`. */
|
|
256
|
+
sendToChannel(request: ChannelIdSend): Promise<Sent>;
|
|
257
|
+
/** Queue a post to a channel by ID, like enqueue(). The channel is checked before it is queued. */
|
|
258
|
+
enqueueToChannel(request: ChannelIdSend): Promise<void>;
|
|
58
259
|
}
|
|
59
260
|
/** The binding's type in a caller's `Env`: `LARRY: LarryBinding`. */
|
|
60
261
|
export type LarryBinding = Service<LarryRpc>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { AllowedMentions, ChannelSend, DirectSend, LarryBinding, LarryRpc, Message, Sent } from './api';
|
|
1
|
+
export type { AllowedMentions, ChannelEdit, ChannelIdSend, ChannelSend, ChannelSyncResult, ChannelsResult, ChannelsSync, DeleteRequest, DeleteResult, Deletion, DirectSend, LarryBinding, LarryRpc, LinkButton, ManagedChannel, MemberRole, Message, MessageRef, RoleSync, RoleSyncResult, RolesResult, RolesSync, Sent, } from './api';
|