@helyx/module-reactionroles 1.0.1
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/CHANGELOG.md +18 -0
- package/LICENSE +725 -0
- package/README.md +53 -0
- package/dist/builder.d.ts +38 -0
- package/dist/builder.js +206 -0
- package/dist/constants.d.ts +22 -0
- package/dist/constants.js +22 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1618 -0
- package/dist/panel-service.d.ts +86 -0
- package/dist/panel-service.js +961 -0
- package/dist/records.d.ts +288 -0
- package/dist/records.js +623 -0
- package/manifest.json +310 -0
- package/migrations/0001_reactionroles_foundation.sql +108 -0
- package/migrations/0002_cleanup_retry_order.sql +6 -0
- package/migrations/0003_persistent_reactions.sql +37 -0
- package/package.json +55 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import type { ModuleRecordService, ModuleRecordWriteValue } from "@helyx/sdk";
|
|
2
|
+
import type { CanonicalEmoji, PanelButtonStyle, PanelControlType, PanelDraft, PanelMessageStyle, PanelSelectionMode } from "./builder.js";
|
|
3
|
+
export declare const reactionRoleRecords: {
|
|
4
|
+
readonly panels: {
|
|
5
|
+
readonly table: "reactionroles_panels";
|
|
6
|
+
readonly fields: {
|
|
7
|
+
readonly panel_id: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
};
|
|
10
|
+
readonly guild_id: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
};
|
|
13
|
+
readonly channel_id: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
readonly message_id: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly optional: true;
|
|
19
|
+
};
|
|
20
|
+
readonly title: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
};
|
|
23
|
+
readonly message_body: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
};
|
|
26
|
+
readonly message_style: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
};
|
|
29
|
+
readonly control_type: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
};
|
|
32
|
+
readonly selection_mode: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
};
|
|
35
|
+
readonly persistent_reactions: {
|
|
36
|
+
readonly type: "boolean";
|
|
37
|
+
};
|
|
38
|
+
readonly embed_colour: {
|
|
39
|
+
readonly type: "number";
|
|
40
|
+
readonly optional: true;
|
|
41
|
+
};
|
|
42
|
+
readonly dropdown_placeholder: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly optional: true;
|
|
45
|
+
};
|
|
46
|
+
readonly status: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
};
|
|
49
|
+
readonly revision: {
|
|
50
|
+
readonly type: "number";
|
|
51
|
+
};
|
|
52
|
+
readonly created_by_user_id: {
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
readonly optional: true;
|
|
55
|
+
};
|
|
56
|
+
readonly updated_by_user_id: {
|
|
57
|
+
readonly type: "string";
|
|
58
|
+
readonly optional: true;
|
|
59
|
+
};
|
|
60
|
+
readonly created_at: {
|
|
61
|
+
readonly type: "date";
|
|
62
|
+
};
|
|
63
|
+
readonly updated_at: {
|
|
64
|
+
readonly type: "date";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
readonly uniqueKeys: readonly [readonly ["panel_id"], readonly ["guild_id", "message_id"]];
|
|
68
|
+
readonly readableFields: readonly ["panel_id", "guild_id", "channel_id", "message_id", "title", "message_body", "message_style", "control_type", "selection_mode", "persistent_reactions", "embed_colour", "dropdown_placeholder", "status", "revision", "created_by_user_id", "updated_by_user_id", "created_at", "updated_at"];
|
|
69
|
+
readonly writableFields: readonly ["channel_id", "message_id", "title", "message_body", "message_style", "control_type", "selection_mode", "persistent_reactions", "embed_colour", "dropdown_placeholder", "status", "revision", "updated_by_user_id", "updated_at"];
|
|
70
|
+
readonly orderKeys: readonly [readonly ["updated_at", "panel_id"]];
|
|
71
|
+
readonly groupableFields: readonly ["status"];
|
|
72
|
+
};
|
|
73
|
+
readonly entries: {
|
|
74
|
+
readonly table: "reactionroles_entries";
|
|
75
|
+
readonly fields: {
|
|
76
|
+
readonly entry_id: {
|
|
77
|
+
readonly type: "string";
|
|
78
|
+
};
|
|
79
|
+
readonly panel_id: {
|
|
80
|
+
readonly type: "string";
|
|
81
|
+
};
|
|
82
|
+
readonly position: {
|
|
83
|
+
readonly type: "number";
|
|
84
|
+
};
|
|
85
|
+
readonly role_id: {
|
|
86
|
+
readonly type: "string";
|
|
87
|
+
};
|
|
88
|
+
readonly nameplate: {
|
|
89
|
+
readonly type: "string";
|
|
90
|
+
};
|
|
91
|
+
readonly emoji_kind: {
|
|
92
|
+
readonly type: "string";
|
|
93
|
+
readonly optional: true;
|
|
94
|
+
};
|
|
95
|
+
readonly emoji_name: {
|
|
96
|
+
readonly type: "string";
|
|
97
|
+
readonly optional: true;
|
|
98
|
+
};
|
|
99
|
+
readonly emoji_id: {
|
|
100
|
+
readonly type: "string";
|
|
101
|
+
readonly optional: true;
|
|
102
|
+
};
|
|
103
|
+
readonly emoji_animated: {
|
|
104
|
+
readonly type: "boolean";
|
|
105
|
+
readonly optional: true;
|
|
106
|
+
};
|
|
107
|
+
readonly button_style: {
|
|
108
|
+
readonly type: "string";
|
|
109
|
+
readonly optional: true;
|
|
110
|
+
};
|
|
111
|
+
readonly created_at: {
|
|
112
|
+
readonly type: "date";
|
|
113
|
+
};
|
|
114
|
+
readonly updated_at: {
|
|
115
|
+
readonly type: "date";
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
readonly uniqueKeys: readonly [readonly ["entry_id"], readonly ["panel_id", "position"], readonly ["panel_id", "role_id"]];
|
|
119
|
+
readonly readableFields: readonly ["entry_id", "panel_id", "position", "role_id", "nameplate", "emoji_kind", "emoji_name", "emoji_id", "emoji_animated", "button_style", "created_at", "updated_at"];
|
|
120
|
+
readonly orderKeys: readonly [readonly ["position", "entry_id"]];
|
|
121
|
+
};
|
|
122
|
+
readonly message_cleanup: {
|
|
123
|
+
readonly table: "reactionroles_message_cleanup";
|
|
124
|
+
readonly fields: {
|
|
125
|
+
readonly cleanup_id: {
|
|
126
|
+
readonly type: "string";
|
|
127
|
+
};
|
|
128
|
+
readonly guild_id: {
|
|
129
|
+
readonly type: "string";
|
|
130
|
+
};
|
|
131
|
+
readonly panel_id: {
|
|
132
|
+
readonly type: "string";
|
|
133
|
+
};
|
|
134
|
+
readonly channel_id: {
|
|
135
|
+
readonly type: "string";
|
|
136
|
+
};
|
|
137
|
+
readonly message_id: {
|
|
138
|
+
readonly type: "string";
|
|
139
|
+
};
|
|
140
|
+
readonly reason: {
|
|
141
|
+
readonly type: "string";
|
|
142
|
+
};
|
|
143
|
+
readonly attempts: {
|
|
144
|
+
readonly type: "number";
|
|
145
|
+
};
|
|
146
|
+
readonly next_attempt_at: {
|
|
147
|
+
readonly type: "date";
|
|
148
|
+
};
|
|
149
|
+
readonly created_at: {
|
|
150
|
+
readonly type: "date";
|
|
151
|
+
};
|
|
152
|
+
readonly completed_at: {
|
|
153
|
+
readonly type: "date";
|
|
154
|
+
readonly optional: true;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
readonly uniqueKeys: readonly [readonly ["cleanup_id"], readonly ["guild_id", "channel_id", "message_id", "reason"]];
|
|
158
|
+
readonly readableFields: readonly ["cleanup_id", "guild_id", "panel_id", "channel_id", "message_id", "reason", "attempts", "next_attempt_at", "created_at", "completed_at"];
|
|
159
|
+
readonly writableFields: readonly ["attempts", "next_attempt_at", "completed_at"];
|
|
160
|
+
readonly orderKeys: readonly [readonly ["next_attempt_at", "cleanup_id"]];
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export type PanelStatus = "pending" | "active" | "disabled" | "message_missing" | "needs_attention" | "cleanup_pending" | "deleting";
|
|
164
|
+
export interface StoredPanel extends PanelDraft {
|
|
165
|
+
panelId: string;
|
|
166
|
+
guildId: string;
|
|
167
|
+
messageId: string | null;
|
|
168
|
+
status: PanelStatus;
|
|
169
|
+
revision: number;
|
|
170
|
+
createdByUserId: string | null;
|
|
171
|
+
updatedByUserId: string | null;
|
|
172
|
+
createdAt: Date;
|
|
173
|
+
updatedAt: Date;
|
|
174
|
+
}
|
|
175
|
+
export interface StoredPanelEntry {
|
|
176
|
+
entryId: string;
|
|
177
|
+
panelId: string;
|
|
178
|
+
position: number;
|
|
179
|
+
roleId: string;
|
|
180
|
+
nameplate: string;
|
|
181
|
+
emoji: CanonicalEmoji | null;
|
|
182
|
+
buttonStyle: PanelButtonStyle | null;
|
|
183
|
+
createdAt: Date;
|
|
184
|
+
updatedAt: Date;
|
|
185
|
+
}
|
|
186
|
+
export interface PendingMessageCleanup {
|
|
187
|
+
cleanupId: string;
|
|
188
|
+
guildId: string;
|
|
189
|
+
panelId: string;
|
|
190
|
+
channelId: string;
|
|
191
|
+
messageId: string;
|
|
192
|
+
reason: "replacement" | "rollback" | "delete";
|
|
193
|
+
attempts: number;
|
|
194
|
+
nextAttemptAt: Date;
|
|
195
|
+
}
|
|
196
|
+
export interface PanelReference {
|
|
197
|
+
panelId: string;
|
|
198
|
+
title: string;
|
|
199
|
+
status: PanelStatus;
|
|
200
|
+
updatedAt: Date;
|
|
201
|
+
}
|
|
202
|
+
export declare class ReactionRolePanelRepository {
|
|
203
|
+
#private;
|
|
204
|
+
private readonly records;
|
|
205
|
+
constructor(records: ModuleRecordService);
|
|
206
|
+
create(input: {
|
|
207
|
+
panelId: string;
|
|
208
|
+
guildId: string;
|
|
209
|
+
actorUserId: string;
|
|
210
|
+
draft: PanelDraft;
|
|
211
|
+
messageId?: string;
|
|
212
|
+
entries: readonly {
|
|
213
|
+
entryId: string;
|
|
214
|
+
roleId: string;
|
|
215
|
+
nameplate: string;
|
|
216
|
+
emoji: CanonicalEmoji | null;
|
|
217
|
+
buttonStyle: PanelButtonStyle | null;
|
|
218
|
+
}[];
|
|
219
|
+
now?: Date;
|
|
220
|
+
}): Promise<boolean>;
|
|
221
|
+
update(input: {
|
|
222
|
+
panel: StoredPanel;
|
|
223
|
+
actorUserId: string;
|
|
224
|
+
draft: PanelDraft;
|
|
225
|
+
messageId?: string | null;
|
|
226
|
+
status?: PanelStatus;
|
|
227
|
+
entries: readonly {
|
|
228
|
+
entryId: string;
|
|
229
|
+
roleId: string;
|
|
230
|
+
nameplate: string;
|
|
231
|
+
emoji: CanonicalEmoji | null;
|
|
232
|
+
buttonStyle: PanelButtonStyle | null;
|
|
233
|
+
}[];
|
|
234
|
+
now?: Date;
|
|
235
|
+
}): Promise<boolean>;
|
|
236
|
+
findById(guildId: string, panelId: string): Promise<StoredPanel | null>;
|
|
237
|
+
findByMessage(guildId: string, messageId: string): Promise<StoredPanel | null>;
|
|
238
|
+
list(input: {
|
|
239
|
+
guildId: string;
|
|
240
|
+
cursor?: readonly ModuleRecordWriteValue[];
|
|
241
|
+
limit: number;
|
|
242
|
+
}): Promise<{
|
|
243
|
+
panels: readonly StoredPanel[];
|
|
244
|
+
nextCursor: readonly ModuleRecordWriteValue[] | null;
|
|
245
|
+
}>;
|
|
246
|
+
listReferences(input: {
|
|
247
|
+
guildId: string;
|
|
248
|
+
cursor?: readonly ModuleRecordWriteValue[];
|
|
249
|
+
limit: number;
|
|
250
|
+
}): Promise<{
|
|
251
|
+
panels: readonly PanelReference[];
|
|
252
|
+
nextCursor: readonly ModuleRecordWriteValue[] | null;
|
|
253
|
+
}>;
|
|
254
|
+
listByChannel(guildId: string, channelId: string, limit?: number): Promise<readonly StoredPanel[]>;
|
|
255
|
+
listByRole(guildId: string, roleId: string, limit?: number): Promise<readonly StoredPanel[]>;
|
|
256
|
+
listByEmoji(guildId: string, emojiId: string, limit?: number): Promise<readonly StoredPanel[]>;
|
|
257
|
+
listInteractive(input: {
|
|
258
|
+
status: "active" | "cleanup_pending";
|
|
259
|
+
cursor?: readonly ModuleRecordWriteValue[];
|
|
260
|
+
limit: number;
|
|
261
|
+
}): Promise<{
|
|
262
|
+
panels: readonly StoredPanel[];
|
|
263
|
+
nextCursor: readonly ModuleRecordWriteValue[] | null;
|
|
264
|
+
}>;
|
|
265
|
+
markStatus(input: {
|
|
266
|
+
panelId: string;
|
|
267
|
+
expectedRevision: number;
|
|
268
|
+
status: PanelStatus;
|
|
269
|
+
actorUserId?: string;
|
|
270
|
+
now?: Date;
|
|
271
|
+
}): Promise<boolean>;
|
|
272
|
+
remove(panelId: string, expectedRevision: number, actorUserId: string): Promise<boolean>;
|
|
273
|
+
claimDeleting(panelId: string, expectedRevision: number, actorUserId: string): Promise<boolean>;
|
|
274
|
+
deleteClaimed(panelId: string): Promise<boolean>;
|
|
275
|
+
recordCleanup(input: {
|
|
276
|
+
guildId: string;
|
|
277
|
+
panelId: string;
|
|
278
|
+
channelId: string;
|
|
279
|
+
messageId: string;
|
|
280
|
+
reason: "replacement" | "rollback" | "delete";
|
|
281
|
+
now?: Date;
|
|
282
|
+
}): Promise<boolean>;
|
|
283
|
+
listPendingCleanup(limit?: number): Promise<readonly PendingMessageCleanup[]>;
|
|
284
|
+
claimCleanup(cleanup: PendingMessageCleanup, now?: Date): Promise<PendingMessageCleanup | null>;
|
|
285
|
+
completeCleanup(cleanup: PendingMessageCleanup, now?: Date): Promise<boolean>;
|
|
286
|
+
pendingCleanupCount(panelId: string): Promise<number>;
|
|
287
|
+
}
|
|
288
|
+
export type { PanelControlType, PanelMessageStyle, PanelSelectionMode };
|