@open-discord-bots/framework 0.3.3 → 0.3.5
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/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/main.d.ts +4 -0
- package/dist/api/main.js +3 -1
- package/dist/api/modules/client.d.ts +13 -12
- package/dist/api/modules/client.js +61 -56
- package/dist/api/modules/console.js +3 -1
- package/dist/api/modules/database.d.ts +1 -1
- package/dist/api/modules/fuse.d.ts +4 -2
- package/dist/api/modules/fuse.js +2 -1
- package/dist/api/modules/permission.d.ts +1 -1
- package/dist/api/modules/permission.js +1 -1
- package/dist/api/modules/post.js +3 -3
- package/dist/api/modules/responder.d.ts +3 -3
- package/dist/api/modules/responder.js +27 -27
- package/dist/api/modules/startscreen.js +2 -2
- package/dist/api/modules/state.d.ts +126 -0
- package/dist/api/modules/state.js +222 -0
- package/dist/startup/errorHandling.js +2 -0
- package/package.json +1 -1
- package/src/api/index.ts +1 -0
- package/src/api/main.ts +6 -1
- package/src/api/modules/client.ts +60 -56
- package/src/api/modules/console.ts +3 -1
- package/src/api/modules/database.ts +1 -1
- package/src/api/modules/fuse.ts +8 -5
- package/src/api/modules/permission.ts +1 -1
- package/src/api/modules/post.ts +3 -3
- package/src/api/modules/responder.ts +31 -31
- package/src/api/modules/startscreen.ts +2 -2
- package/src/api/modules/state.ts +294 -0
- package/src/startup/errorHandling.ts +3 -0
|
@@ -123,7 +123,7 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
123
123
|
}
|
|
124
124
|
/**Get all servers the bot is part of. */
|
|
125
125
|
async getGuilds(): Promise<discord.Guild[]> {
|
|
126
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
126
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager() => Unable to use this method. Client isn't initiated yet.")
|
|
127
127
|
if (!this.ready) throw new ODSystemError("Client isn't ready yet!")
|
|
128
128
|
|
|
129
129
|
return this.client.guilds.cache.map((guild) => guild)
|
|
@@ -146,15 +146,15 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
146
146
|
/**Log-in with a discord auth token. Rejects returns `false` using 'softErrors' on failure. */
|
|
147
147
|
login(softErrors?:boolean): Promise<boolean> {
|
|
148
148
|
return new Promise(async (resolve,reject) => {
|
|
149
|
-
if (!this.initiated) reject("Client isn't initiated yet
|
|
150
|
-
if (!this.token) reject("
|
|
149
|
+
if (!this.initiated) reject("ODClientManager.login() => Unable to use this method. Client isn't initiated yet.")
|
|
150
|
+
if (!this.token) reject("ODClientManager.login() => Unable to login, client does not have a token.")
|
|
151
151
|
|
|
152
152
|
try {
|
|
153
153
|
this.client.once("clientReady",async () => {
|
|
154
154
|
this.ready = true
|
|
155
155
|
|
|
156
156
|
//set slashCommandManager & contextMenuManager to client applicationCommandManager
|
|
157
|
-
if (!this.client.application) throw new ODSystemError("
|
|
157
|
+
if (!this.client.application) throw new ODSystemError("ODClientManager.login() => Unable to fetch client application for slashCommand & contextMenu managers.")
|
|
158
158
|
this.slashCommands.commandManager = this.client.application.commands
|
|
159
159
|
this.contextMenus.commandManager = this.client.application.commands
|
|
160
160
|
this.autocompletes.commandManager = this.client.application.commands
|
|
@@ -177,10 +177,10 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
177
177
|
}
|
|
178
178
|
})
|
|
179
179
|
}
|
|
180
|
-
/**A simplified shortcut to get a `discord.User
|
|
180
|
+
/**A simplified shortcut to get a `discord.User`. */
|
|
181
181
|
async fetchUser(id:string): Promise<discord.User|null> {
|
|
182
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
183
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
182
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchUser() => Unable to use this method. Client isn't initiated yet.")
|
|
183
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchUser() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
184
184
|
|
|
185
185
|
try{
|
|
186
186
|
return await this.client.users.fetch(id)
|
|
@@ -188,10 +188,10 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
188
188
|
return null
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
/**A simplified shortcut to get a `discord.Guild
|
|
191
|
+
/**A simplified shortcut to get a `discord.Guild`. */
|
|
192
192
|
async fetchGuild(id:string): Promise<discord.Guild|null> {
|
|
193
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
194
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
193
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchGuild() => Unable to use this method. Client isn't initiated yet.")
|
|
194
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchGuild() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
195
195
|
|
|
196
196
|
try{
|
|
197
197
|
return await this.client.guilds.fetch(id)
|
|
@@ -199,10 +199,10 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
199
199
|
return null
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
/**A simplified shortcut to get a `discord.Channel
|
|
202
|
+
/**A simplified shortcut to get a `discord.Channel`. */
|
|
203
203
|
async fetchChannel(id:string): Promise<discord.Channel|null> {
|
|
204
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
205
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
204
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchChannel() => Unable to use this method. Client isn't initiated yet.")
|
|
205
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchChannel() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
206
206
|
|
|
207
207
|
try{
|
|
208
208
|
return await this.client.channels.fetch(id)
|
|
@@ -210,10 +210,23 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
210
210
|
return null
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
/**A simplified shortcut to get a `discord.
|
|
213
|
+
/**A simplified shortcut to get a `discord.TextChannel` (guild or DM). */
|
|
214
|
+
async fetchTextChannel(id:string): Promise<discord.TextChannel|discord.DMChannel|discord.PartialDMChannel|null> {
|
|
215
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchTextChannel() => Unable to use this method. Client isn't initiated yet.")
|
|
216
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchTextChannel() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
217
|
+
|
|
218
|
+
try{
|
|
219
|
+
const channel = await this.client.channels.fetch(id)
|
|
220
|
+
if (!channel || (channel.type != discord.ChannelType.GuildText && channel.type != discord.ChannelType.DM)) return null
|
|
221
|
+
return channel
|
|
222
|
+
}catch{
|
|
223
|
+
return null
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**A simplified shortcut to get a `discord.GuildBasedChannel`. */
|
|
214
227
|
async fetchGuildChannel(guildId:string|discord.Guild, id:string): Promise<discord.GuildBasedChannel|null> {
|
|
215
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
216
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
228
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchGuildChannel() => Unable to use this method. Client isn't initiated yet.")
|
|
229
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchGuildChannel() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
217
230
|
|
|
218
231
|
try{
|
|
219
232
|
const guild = (guildId instanceof discord.Guild) ? guildId : await this.fetchGuild(guildId)
|
|
@@ -224,10 +237,10 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
224
237
|
return null
|
|
225
238
|
}
|
|
226
239
|
}
|
|
227
|
-
/**A simplified shortcut to get a `discord.TextChannel
|
|
240
|
+
/**A simplified shortcut to get a `discord.TextChannel`. */
|
|
228
241
|
async fetchGuildTextChannel(guildId:string|discord.Guild, id:string): Promise<discord.TextChannel|null> {
|
|
229
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
230
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
242
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchGuildTextChannel() => Unable to use this method. Client isn't initiated yet.")
|
|
243
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchGuildTextChannel() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
231
244
|
|
|
232
245
|
try{
|
|
233
246
|
const guild = (guildId instanceof discord.Guild) ? guildId : await this.fetchGuild(guildId)
|
|
@@ -239,10 +252,10 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
239
252
|
return null
|
|
240
253
|
}
|
|
241
254
|
}
|
|
242
|
-
/**A simplified shortcut to get a `discord.CategoryChannel
|
|
255
|
+
/**A simplified shortcut to get a `discord.CategoryChannel`. */
|
|
243
256
|
async fetchGuildCategoryChannel(guildId:string|discord.Guild, id:string): Promise<discord.CategoryChannel|null> {
|
|
244
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
245
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
257
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchGuildCategoryChannel() => Unable to use this method. Client isn't initiated yet.")
|
|
258
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchGuildCategoryChannel() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
246
259
|
|
|
247
260
|
try{
|
|
248
261
|
const guild = (guildId instanceof discord.Guild) ? guildId : await this.fetchGuild(guildId)
|
|
@@ -254,12 +267,11 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
254
267
|
return null
|
|
255
268
|
}
|
|
256
269
|
}
|
|
257
|
-
/**A simplified shortcut to get a `discord.GuildMember
|
|
270
|
+
/**A simplified shortcut to get a `discord.GuildMember`. */
|
|
258
271
|
async fetchGuildMember(guildId:string|discord.Guild, id:string): Promise<discord.GuildMember|null> {
|
|
259
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
260
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
261
|
-
|
|
262
|
-
|
|
272
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchGuildMember() => Unable to use this method. Client isn't initiated yet.")
|
|
273
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchGuildMember() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
274
|
+
|
|
263
275
|
try{
|
|
264
276
|
const guild = (guildId instanceof discord.Guild) ? guildId : await this.fetchGuild(guildId)
|
|
265
277
|
if (!guild) return null
|
|
@@ -268,12 +280,11 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
268
280
|
return null
|
|
269
281
|
}
|
|
270
282
|
}
|
|
271
|
-
/**A simplified shortcut to get a `discord.Role
|
|
283
|
+
/**A simplified shortcut to get a `discord.Role`. */
|
|
272
284
|
async fetchGuildRole(guildId:string|discord.Guild, id:string): Promise<discord.Role|null> {
|
|
273
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
274
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
275
|
-
|
|
276
|
-
|
|
285
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchGuildRole() => Unable to use this method. Client isn't initiated yet.")
|
|
286
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchGuildRole() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
287
|
+
|
|
277
288
|
try{
|
|
278
289
|
const guild = (guildId instanceof discord.Guild) ? guildId : await this.fetchGuild(guildId)
|
|
279
290
|
if (!guild) return null
|
|
@@ -282,30 +293,23 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
282
293
|
return null
|
|
283
294
|
}
|
|
284
295
|
}
|
|
285
|
-
/**A simplified shortcut to get a `discord.Message
|
|
286
|
-
async
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet!")
|
|
290
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet!")
|
|
296
|
+
/**A simplified shortcut to get a `discord.Message`. */
|
|
297
|
+
async fetchChannelMessage(channelId:string|discord.TextChannel|discord.DMChannel, id:string): Promise<discord.Message<boolean>|null> {
|
|
298
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.fetchChannelMessage() => Unable to use this method. Client isn't initiated yet.")
|
|
299
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.fetchChannelMessage() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
291
300
|
|
|
292
301
|
try{
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}else if (!(guildId instanceof discord.TextChannel) && id){
|
|
297
|
-
const channel = (channelId instanceof discord.TextChannel) ? channelId : await this.fetchGuildTextChannel(guildId,channelId)
|
|
298
|
-
if (!channel) return null
|
|
299
|
-
return await channel.messages.fetch(id)
|
|
300
|
-
}else return null
|
|
302
|
+
const channel = (channelId instanceof discord.TextChannel || channelId instanceof discord.DMChannel) ? channelId : await this.fetchTextChannel(channelId)
|
|
303
|
+
if (!channel) return null
|
|
304
|
+
return await channel.messages.fetch(id)
|
|
301
305
|
}catch{
|
|
302
306
|
return null
|
|
303
307
|
}
|
|
304
308
|
}
|
|
305
|
-
/**A simplified shortcut to send a DM to a user
|
|
309
|
+
/**A simplified shortcut to send a DM to a user. */
|
|
306
310
|
async sendUserDm(user:string|discord.User, build:ODMessageBuildResult|ODMessageComponentBuildResult): Promise<ODResponderSendResult<false>> {
|
|
307
|
-
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet
|
|
308
|
-
if (!this.ready) throw new ODSystemError("Client isn't ready yet
|
|
311
|
+
if (!this.initiated) throw new ODSystemError("ODClientManager.sendUserDm() => Unable to use this method. Client isn't initiated yet.")
|
|
312
|
+
if (!this.ready) throw new ODSystemError("ODClientManager.sendUserDm() => Unable to use this method. Client isn't ready and logged in yet.")
|
|
309
313
|
|
|
310
314
|
try{
|
|
311
315
|
const msgFlags: number[] = []
|
|
@@ -325,26 +329,26 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
|
|
|
325
329
|
const finalMessage = Object.assign(msgData,{flags:msgFlags})
|
|
326
330
|
|
|
327
331
|
if (user instanceof discord.User){
|
|
328
|
-
if (user.bot) return {success:false
|
|
332
|
+
if (user.bot) return {success:false}
|
|
329
333
|
const channel = await user.createDM()
|
|
330
334
|
const msg = await channel.send(finalMessage)
|
|
331
|
-
return {success:true,message:msg}
|
|
335
|
+
return {success:true,message:msg,ephemeral:false}
|
|
332
336
|
}else{
|
|
333
337
|
const newUser = await this.fetchUser(user)
|
|
334
338
|
if (!newUser) throw new Error()
|
|
335
|
-
if (newUser.bot) return {success:false
|
|
339
|
+
if (newUser.bot) return {success:false}
|
|
336
340
|
const channel = await newUser.createDM()
|
|
337
341
|
const msg = await channel.send(finalMessage)
|
|
338
|
-
return {success:true,message:msg}
|
|
342
|
+
return {success:true,message:msg,ephemeral:false}
|
|
339
343
|
}
|
|
340
344
|
}catch{
|
|
341
345
|
try{
|
|
342
|
-
this.debug.console.log("Failed to send DM
|
|
346
|
+
this.debug.console.log("ODClientManager.sendUserDm() => Failed to send DM. User may have DMs disabled for non-friends. ","warning",[
|
|
343
347
|
{key:"id",value:(user instanceof discord.User ? user.id : user)},
|
|
344
348
|
{key:"message-build",value:build.id.value}
|
|
345
349
|
])
|
|
346
350
|
}catch{}
|
|
347
|
-
return {success:false
|
|
351
|
+
return {success:false}
|
|
348
352
|
}
|
|
349
353
|
}
|
|
350
354
|
}
|
|
@@ -417,7 +421,7 @@ export class ODClientActivityManager {
|
|
|
417
421
|
|
|
418
422
|
/**Update the client status */
|
|
419
423
|
private updateClientActivity(type:ODClientActivityType,text:string){
|
|
420
|
-
if (!this.client.client.user) throw new ODSystemError("Couldn't set client status: client.user
|
|
424
|
+
if (!this.client.client.user) throw new ODSystemError("ODClientActivityManager.updateClientActivity() => Couldn't set client status: client.user is 'undefined'.")
|
|
421
425
|
if (type == false){
|
|
422
426
|
this.client.client.user.setActivity()
|
|
423
427
|
return
|
|
@@ -217,7 +217,9 @@ export class ODError {
|
|
|
217
217
|
}
|
|
218
218
|
/**Create a more-detailed, non-colored version of this error to store it in the `debug.txt` file! */
|
|
219
219
|
toDebugString(){
|
|
220
|
-
|
|
220
|
+
const date = new Date()
|
|
221
|
+
const dstring = `${date.getDate()}/${date.getMonth()+1}/${date.getFullYear()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`
|
|
222
|
+
return "["+dstring+" UNKNOWN OPENDISCORD ERROR]: "+this.error.message+" | Error Origin: "+this.origin+" | Stacktrace:\n"+this.error.stack
|
|
221
223
|
}
|
|
222
224
|
}
|
|
223
225
|
|
|
@@ -89,7 +89,7 @@ export abstract class ODDatabase<IdList extends ODDatabaseIdConstraint = ODDatab
|
|
|
89
89
|
abstract get(category:string, key:string): ODOptionalPromise<ODValidJsonType|undefined>
|
|
90
90
|
abstract get(category:string, key:string): ODOptionalPromise<ODValidJsonType|undefined>
|
|
91
91
|
|
|
92
|
-
/**Delete a specific category & key in the database */
|
|
92
|
+
/**Delete a specific category & key in the database. Returns `true` when deleted. */
|
|
93
93
|
abstract delete<CategoryId extends keyof ODNoGeneric<IdList>>(category:CategoryId, key:string): ODOptionalPromise<boolean>
|
|
94
94
|
abstract delete(category:string, key:string): ODOptionalPromise<boolean>
|
|
95
95
|
abstract delete(category:string, key:string): ODOptionalPromise<boolean>
|
package/src/api/modules/fuse.ts
CHANGED
|
@@ -142,9 +142,6 @@ export interface ODSharedFuseList {
|
|
|
142
142
|
/**Load the default Open Discord client activity initialization (& status refresh). */
|
|
143
143
|
clientActivityInitiating:boolean,
|
|
144
144
|
|
|
145
|
-
/**Load the default Open Discord priority levels. */
|
|
146
|
-
priorityLoading:boolean,
|
|
147
|
-
|
|
148
145
|
/**Load the default Open Discord slash commands. */
|
|
149
146
|
slashCommandLoading:boolean,
|
|
150
147
|
/**Load the default Open Discord slash command registerer (register slash cmds in discord). */
|
|
@@ -164,6 +161,11 @@ export interface ODSharedFuseList {
|
|
|
164
161
|
/**Load the default Open Discord text commands. */
|
|
165
162
|
textCommandLoading:boolean,
|
|
166
163
|
|
|
164
|
+
/**Load the default Open Discord message states. */
|
|
165
|
+
stateLoading:boolean,
|
|
166
|
+
/**Initiate the default Open Discord message states. */
|
|
167
|
+
stateInitiating:boolean,
|
|
168
|
+
|
|
167
169
|
/**Load the default Open Discord button builders. */
|
|
168
170
|
buttonBuildersLoading:boolean,
|
|
169
171
|
/**Load the default Open Discord dropdown builders. */
|
|
@@ -298,8 +300,6 @@ export class ODSharedFuseManager extends ODFuseManager<ODSharedFuseList> {
|
|
|
298
300
|
clientActivityLoading:true,
|
|
299
301
|
clientActivityInitiating:true,
|
|
300
302
|
|
|
301
|
-
priorityLoading:true,
|
|
302
|
-
|
|
303
303
|
slashCommandLoading:true,
|
|
304
304
|
slashCommandRegistering:true,
|
|
305
305
|
forceSlashCommandRegistration:false,
|
|
@@ -310,6 +310,9 @@ export class ODSharedFuseManager extends ODFuseManager<ODSharedFuseList> {
|
|
|
310
310
|
allowContextMenuRemoval:true,
|
|
311
311
|
textCommandLoading:true,
|
|
312
312
|
|
|
313
|
+
stateLoading:true,
|
|
314
|
+
stateInitiating:true,
|
|
315
|
+
|
|
313
316
|
buttonBuildersLoading:true,
|
|
314
317
|
dropdownBuildersLoading:true,
|
|
315
318
|
fileBuildersLoading:true,
|
|
@@ -310,7 +310,7 @@ export class ODPermissionManager<IdList extends ODPermissionManagerIdConstraint
|
|
|
310
310
|
return {...this.defaultResult}
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
/**Check the permissions for a certain command of the bot. */
|
|
313
|
+
/**Check the permissions for a certain command of the bot. Permission mode: `none`, `everyone`, `admin` or any valid discord role ID. */
|
|
314
314
|
async checkCommandPerms(permissionMode:string,requiredLevel:ODPermissionType,user:discord.User,member?:discord.GuildMember|null,channel?:discord.Channel|null,guild?:discord.Guild|null,settings?:ODPermissionSettings): Promise<ODPermissionCommandResult> {
|
|
315
315
|
if (permissionMode === "none"){
|
|
316
316
|
return {hasPerms:false,reason:"disabled"}
|
package/src/api/modules/post.ts
CHANGED
|
@@ -107,13 +107,13 @@ export class ODPost<ChannelType extends discord.GuildBasedChannel> extends ODMan
|
|
|
107
107
|
}
|
|
108
108
|
/**Send a message to this channel using the Open Discord builder system */
|
|
109
109
|
async send(build:ODMessageBuildResult|ODMessageComponentBuildResult): Promise<ODResponderSendResult<true>> {
|
|
110
|
-
if (!this.channel || !this.channel.isTextBased()) return {success:false
|
|
110
|
+
if (!this.channel || !this.channel.isTextBased()) return {success:false}
|
|
111
111
|
try{
|
|
112
112
|
const finalMessage = this.getMessageFromBuildResult(build,"message")
|
|
113
113
|
const sent = await this.channel.send(finalMessage)
|
|
114
|
-
return {success:true,message:sent}
|
|
114
|
+
return {success:true,message:sent,ephemeral:false}
|
|
115
115
|
}catch{
|
|
116
|
-
return {success:false
|
|
116
|
+
return {success:false}
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
/**Get the final `messageCreateOptions` from a returned build result from builders/components. */
|
|
@@ -44,12 +44,12 @@ export type ODResponderSendResult<InGuild extends boolean> = {
|
|
|
44
44
|
/**Did the message get sent successfully? */
|
|
45
45
|
success:true,
|
|
46
46
|
/**The message that got sent. */
|
|
47
|
-
message:discord.Message<InGuild
|
|
47
|
+
message:discord.Message<InGuild>,
|
|
48
|
+
/**Was the message sent as ephemeral? */
|
|
49
|
+
ephemeral:boolean
|
|
48
50
|
} | {
|
|
49
51
|
/**Did the message get sent successfully? */
|
|
50
|
-
success:
|
|
51
|
-
/**The message that got sent. */
|
|
52
|
-
message:null
|
|
52
|
+
success:false
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**## ODResponderManager `class`
|
|
@@ -475,19 +475,19 @@ export class ODCommandResponderInstance extends ODBaseResponderInstance {
|
|
|
475
475
|
if (this.interaction.replied || this.interaction.deferred){
|
|
476
476
|
const sent = await this.interaction.editReply(finalMessage)
|
|
477
477
|
this.ignoreResponderTimeout = true
|
|
478
|
-
return {success:true,message:sent}
|
|
478
|
+
return {success:true,message:sent,ephemeral:build.ephemeral}
|
|
479
479
|
}else{
|
|
480
480
|
const sent = await this.interaction.reply(finalMessage)
|
|
481
481
|
this.ignoreResponderTimeout = true
|
|
482
|
-
return {success:true,message:await sent.fetch()}
|
|
482
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
483
483
|
}
|
|
484
484
|
}else if (this.type == "message" && this.interaction instanceof discord.Message && this.interaction.channel.type != discord.ChannelType.GroupDM){
|
|
485
485
|
const sent = await this.interaction.channel.send(finalMessage)
|
|
486
486
|
this.ignoreResponderTimeout = true
|
|
487
|
-
return {success:true,message:sent}
|
|
488
|
-
}else return {success:false
|
|
487
|
+
return {success:true,message:sent,ephemeral:false}
|
|
488
|
+
}else return {success:false}
|
|
489
489
|
}catch{
|
|
490
|
-
return {success:false
|
|
490
|
+
return {success:false}
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
/**Defer this command. */
|
|
@@ -663,14 +663,14 @@ export class ODButtonResponderInstance extends ODBaseResponderInstance {
|
|
|
663
663
|
if (this.interaction.replied || this.interaction.deferred){
|
|
664
664
|
const sent = await this.interaction.editReply(finalMessage)
|
|
665
665
|
this.ignoreResponderTimeout = true
|
|
666
|
-
return {success:true,message:sent}
|
|
666
|
+
return {success:true,message:sent,ephemeral:build.ephemeral}
|
|
667
667
|
}else{
|
|
668
668
|
const sent = await this.interaction.reply(finalMessage)
|
|
669
669
|
this.ignoreResponderTimeout = true
|
|
670
|
-
return {success:true,message:await sent.fetch()}
|
|
670
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
671
671
|
}
|
|
672
672
|
}catch{
|
|
673
|
-
return {success:false
|
|
673
|
+
return {success:false}
|
|
674
674
|
}
|
|
675
675
|
}
|
|
676
676
|
/**Update the message of this button. */
|
|
@@ -680,14 +680,14 @@ export class ODButtonResponderInstance extends ODBaseResponderInstance {
|
|
|
680
680
|
if (this.interaction.replied || this.interaction.deferred){
|
|
681
681
|
const sent = await this.interaction.editReply(finalMessage)
|
|
682
682
|
this.ignoreResponderTimeout = true
|
|
683
|
-
return {success:true,message:await sent.fetch()}
|
|
683
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
684
684
|
}else{
|
|
685
685
|
const sent = await this.interaction.update(finalMessage)
|
|
686
686
|
this.ignoreResponderTimeout = true
|
|
687
|
-
return {success:true,message:await sent.fetch()}
|
|
687
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
688
688
|
}
|
|
689
689
|
}catch{
|
|
690
|
-
return {success:false
|
|
690
|
+
return {success:false}
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
/**Defer this button. */
|
|
@@ -978,14 +978,14 @@ export class ODDropdownResponderInstance extends ODBaseResponderInstance {
|
|
|
978
978
|
if (this.interaction.replied || this.interaction.deferred){
|
|
979
979
|
const sent = await this.interaction.editReply(finalMessage)
|
|
980
980
|
this.ignoreResponderTimeout = true
|
|
981
|
-
return {success:true,message:sent}
|
|
981
|
+
return {success:true,message:sent,ephemeral:build.ephemeral}
|
|
982
982
|
}else{
|
|
983
983
|
const sent = await this.interaction.reply(finalMessage)
|
|
984
984
|
this.ignoreResponderTimeout = true
|
|
985
|
-
return {success:true,message:await sent.fetch()}
|
|
985
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
986
986
|
}
|
|
987
987
|
}catch{
|
|
988
|
-
return {success:false
|
|
988
|
+
return {success:false}
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
991
|
/**Update the message of this dropdown. */
|
|
@@ -995,14 +995,14 @@ export class ODDropdownResponderInstance extends ODBaseResponderInstance {
|
|
|
995
995
|
if (this.interaction.replied || this.interaction.deferred){
|
|
996
996
|
const sent = await this.interaction.editReply(finalMessage)
|
|
997
997
|
this.ignoreResponderTimeout = true
|
|
998
|
-
return {success:true,message:await sent.fetch()}
|
|
998
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
999
999
|
}else{
|
|
1000
1000
|
const sent = await this.interaction.update(finalMessage)
|
|
1001
1001
|
this.ignoreResponderTimeout = true
|
|
1002
|
-
return {success:true,message:await sent.fetch()}
|
|
1002
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
1003
1003
|
}
|
|
1004
1004
|
}catch{
|
|
1005
|
-
return {success:false
|
|
1005
|
+
return {success:false}
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
1008
|
/**Defer this dropdown. */
|
|
@@ -1227,9 +1227,9 @@ export class ODModalResponderInstance extends ODBaseResponderInstance {
|
|
|
1227
1227
|
const finalMessage = this.getMessageFromBuildResult(build,"interaction")
|
|
1228
1228
|
const sent = await this.interaction.followUp(finalMessage)
|
|
1229
1229
|
this.ignoreResponderTimeout = true
|
|
1230
|
-
return {success:true,message:sent}
|
|
1230
|
+
return {success:true,message:sent,ephemeral:build.ephemeral}
|
|
1231
1231
|
}catch{
|
|
1232
|
-
return {success:false
|
|
1232
|
+
return {success:false}
|
|
1233
1233
|
}
|
|
1234
1234
|
}
|
|
1235
1235
|
/**Update the message of this modal. */
|
|
@@ -1239,14 +1239,14 @@ export class ODModalResponderInstance extends ODBaseResponderInstance {
|
|
|
1239
1239
|
if (this.interaction.replied || this.interaction.deferred){
|
|
1240
1240
|
const sent = await this.interaction.editReply(finalMessage)
|
|
1241
1241
|
this.ignoreResponderTimeout = true
|
|
1242
|
-
return {success:true,message:await sent.fetch()}
|
|
1242
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
1243
1243
|
}else{
|
|
1244
1244
|
const sent = await this.interaction.reply(finalMessage)
|
|
1245
1245
|
this.ignoreResponderTimeout = true
|
|
1246
|
-
return {success:true,message:await sent.fetch()}
|
|
1246
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
1247
1247
|
}
|
|
1248
1248
|
}catch{
|
|
1249
|
-
return {success:false
|
|
1249
|
+
return {success:false}
|
|
1250
1250
|
}
|
|
1251
1251
|
}
|
|
1252
1252
|
/**Defer this modal. */
|
|
@@ -1407,14 +1407,14 @@ export class ODContextMenuResponderInstance extends ODBaseResponderInstance {
|
|
|
1407
1407
|
if (this.interaction.replied || this.interaction.deferred){
|
|
1408
1408
|
const sent = await this.interaction.editReply(finalMessage)
|
|
1409
1409
|
this.ignoreResponderTimeout = true
|
|
1410
|
-
return {success:true,message:sent}
|
|
1410
|
+
return {success:true,message:sent,ephemeral:build.ephemeral}
|
|
1411
1411
|
}else{
|
|
1412
1412
|
const sent = await this.interaction.reply(finalMessage)
|
|
1413
1413
|
this.ignoreResponderTimeout = true
|
|
1414
|
-
return {success:true,message:await sent.fetch()}
|
|
1414
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
1415
1415
|
}
|
|
1416
1416
|
}catch{
|
|
1417
|
-
return {success:false
|
|
1417
|
+
return {success:false}
|
|
1418
1418
|
}
|
|
1419
1419
|
}
|
|
1420
1420
|
/**Update the message of this context menu. */
|
|
@@ -1424,10 +1424,10 @@ export class ODContextMenuResponderInstance extends ODBaseResponderInstance {
|
|
|
1424
1424
|
if (this.interaction.replied || this.interaction.deferred){
|
|
1425
1425
|
const sent = await this.interaction.editReply(finalMessage)
|
|
1426
1426
|
this.ignoreResponderTimeout = true
|
|
1427
|
-
return {success:true,message:await sent.fetch()}
|
|
1427
|
+
return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
|
|
1428
1428
|
}else throw new ODSystemError("Unable to update context menu interaction!")
|
|
1429
1429
|
}catch{
|
|
1430
|
-
return {success:false
|
|
1430
|
+
return {success:false}
|
|
1431
1431
|
}
|
|
1432
1432
|
}
|
|
1433
1433
|
/**Defer this context menu. */
|
|
@@ -232,7 +232,7 @@ export class ODStartScreenCategoryComponent extends ODStartScreenComponent {
|
|
|
232
232
|
super(id,priority,async (location) => {
|
|
233
233
|
const contents = await render(location)
|
|
234
234
|
if (contents != "" || this.renderIfEmpty){
|
|
235
|
-
return ansis.bold.underline("\n"+name.toUpperCase()+(contents != "" ? ":\n" : ":")) + contents
|
|
235
|
+
return ansis.bold.underline("\n"+this.name.toUpperCase()+(contents != "" ? ":\n" : ":")) + contents
|
|
236
236
|
}else return ""
|
|
237
237
|
})
|
|
238
238
|
this.name = name
|
|
@@ -324,7 +324,7 @@ export class ODStartScreenLiveStatusCategoryComponent<LiveStatus extends ODLiveS
|
|
|
324
324
|
livestatus: LiveStatus
|
|
325
325
|
|
|
326
326
|
constructor(id:ODValidId, priority:number, livestatus:LiveStatus){
|
|
327
|
-
super(id,priority,"
|
|
327
|
+
super(id,priority,"news & updates",async () => {
|
|
328
328
|
const messages = await this.livestatus.getAllMessages()
|
|
329
329
|
return this.livestatus.renderer.render(messages)
|
|
330
330
|
},false)
|