@open-discord-bots/framework 0.3.4 → 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/main.js CHANGED
@@ -44,7 +44,7 @@ export class ODMain {
44
44
  constructor(managers, project) {
45
45
  this.project = project;
46
46
  this.versions = managers.versions;
47
- this.versions.add(ODVersion.fromString("opendiscord:api", "v0.3.4"));
47
+ this.versions.add(ODVersion.fromString("opendiscord:api", "v0.3.5"));
48
48
  this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
49
49
  this.debugfile = managers.debugfile;
50
50
  this.console = managers.console;
@@ -348,7 +348,7 @@ export class ODClientManager {
348
348
  return { success: false };
349
349
  const channel = await user.createDM();
350
350
  const msg = await channel.send(finalMessage);
351
- return { success: true, message: msg };
351
+ return { success: true, message: msg, ephemeral: false };
352
352
  }
353
353
  else {
354
354
  const newUser = await this.fetchUser(user);
@@ -358,7 +358,7 @@ export class ODClientManager {
358
358
  return { success: false };
359
359
  const channel = await newUser.createDM();
360
360
  const msg = await channel.send(finalMessage);
361
- return { success: true, message: msg };
361
+ return { success: true, message: msg, ephemeral: false };
362
362
  }
363
363
  }
364
364
  catch {
@@ -129,7 +129,7 @@ export declare class ODPermissionManager<IdList extends ODPermissionManagerIdCon
129
129
  private defaultGlobalCalculation;
130
130
  /**Check for channel permissions. Result will be compared with the global perms in `#defaultCalculation()`. */
131
131
  private defaultChannelCalculation;
132
- /**Check the permissions for a certain command of the bot. */
132
+ /**Check the permissions for a certain command of the bot. Permission mode: `none`, `everyone`, `admin` or any valid discord role ID. */
133
133
  checkCommandPerms(permissionMode: string, requiredLevel: ODPermissionType, user: discord.User, member?: discord.GuildMember | null, channel?: discord.Channel | null, guild?: discord.Guild | null, settings?: ODPermissionSettings): Promise<ODPermissionCommandResult>;
134
134
  get<PermissionId extends keyof ODNoGeneric<IdList>>(id: PermissionId): IdList[PermissionId];
135
135
  get(id: ODValidId): ODPermission | null;
@@ -238,7 +238,7 @@ export class ODPermissionManager extends ODManager {
238
238
  //spread result to prevent accidental modification because of referencing
239
239
  return { ...this.defaultResult };
240
240
  }
241
- /**Check the permissions for a certain command of the bot. */
241
+ /**Check the permissions for a certain command of the bot. Permission mode: `none`, `everyone`, `admin` or any valid discord role ID. */
242
242
  async checkCommandPerms(permissionMode, requiredLevel, user, member, channel, guild, settings) {
243
243
  if (permissionMode === "none") {
244
244
  return { hasPerms: false, reason: "disabled" };
@@ -89,7 +89,7 @@ export class ODPost extends ODManagerData {
89
89
  try {
90
90
  const finalMessage = this.getMessageFromBuildResult(build, "message");
91
91
  const sent = await this.channel.send(finalMessage);
92
- return { success: true, message: sent };
92
+ return { success: true, message: sent, ephemeral: false };
93
93
  }
94
94
  catch {
95
95
  return { success: false };
@@ -33,6 +33,8 @@ export type ODResponderSendResult<InGuild extends boolean> = {
33
33
  success: true;
34
34
  /**The message that got sent. */
35
35
  message: discord.Message<InGuild>;
36
+ /**Was the message sent as ephemeral? */
37
+ ephemeral: boolean;
36
38
  } | {
37
39
  /**Did the message get sent successfully? */
38
40
  success: false;
@@ -428,18 +428,18 @@ export class ODCommandResponderInstance extends ODBaseResponderInstance {
428
428
  if (this.interaction.replied || this.interaction.deferred) {
429
429
  const sent = await this.interaction.editReply(finalMessage);
430
430
  this.ignoreResponderTimeout = true;
431
- return { success: true, message: sent };
431
+ return { success: true, message: sent, ephemeral: build.ephemeral };
432
432
  }
433
433
  else {
434
434
  const sent = await this.interaction.reply(finalMessage);
435
435
  this.ignoreResponderTimeout = true;
436
- return { success: true, message: await sent.fetch() };
436
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
437
437
  }
438
438
  }
439
439
  else if (this.type == "message" && this.interaction instanceof discord.Message && this.interaction.channel.type != discord.ChannelType.GroupDM) {
440
440
  const sent = await this.interaction.channel.send(finalMessage);
441
441
  this.ignoreResponderTimeout = true;
442
- return { success: true, message: sent };
442
+ return { success: true, message: sent, ephemeral: false };
443
443
  }
444
444
  else
445
445
  return { success: false };
@@ -600,12 +600,12 @@ export class ODButtonResponderInstance extends ODBaseResponderInstance {
600
600
  if (this.interaction.replied || this.interaction.deferred) {
601
601
  const sent = await this.interaction.editReply(finalMessage);
602
602
  this.ignoreResponderTimeout = true;
603
- return { success: true, message: sent };
603
+ return { success: true, message: sent, ephemeral: build.ephemeral };
604
604
  }
605
605
  else {
606
606
  const sent = await this.interaction.reply(finalMessage);
607
607
  this.ignoreResponderTimeout = true;
608
- return { success: true, message: await sent.fetch() };
608
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
609
609
  }
610
610
  }
611
611
  catch {
@@ -619,12 +619,12 @@ export class ODButtonResponderInstance extends ODBaseResponderInstance {
619
619
  if (this.interaction.replied || this.interaction.deferred) {
620
620
  const sent = await this.interaction.editReply(finalMessage);
621
621
  this.ignoreResponderTimeout = true;
622
- return { success: true, message: await sent.fetch() };
622
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
623
623
  }
624
624
  else {
625
625
  const sent = await this.interaction.update(finalMessage);
626
626
  this.ignoreResponderTimeout = true;
627
- return { success: true, message: await sent.fetch() };
627
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
628
628
  }
629
629
  }
630
630
  catch {
@@ -908,12 +908,12 @@ export class ODDropdownResponderInstance extends ODBaseResponderInstance {
908
908
  if (this.interaction.replied || this.interaction.deferred) {
909
909
  const sent = await this.interaction.editReply(finalMessage);
910
910
  this.ignoreResponderTimeout = true;
911
- return { success: true, message: sent };
911
+ return { success: true, message: sent, ephemeral: build.ephemeral };
912
912
  }
913
913
  else {
914
914
  const sent = await this.interaction.reply(finalMessage);
915
915
  this.ignoreResponderTimeout = true;
916
- return { success: true, message: await sent.fetch() };
916
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
917
917
  }
918
918
  }
919
919
  catch {
@@ -927,12 +927,12 @@ export class ODDropdownResponderInstance extends ODBaseResponderInstance {
927
927
  if (this.interaction.replied || this.interaction.deferred) {
928
928
  const sent = await this.interaction.editReply(finalMessage);
929
929
  this.ignoreResponderTimeout = true;
930
- return { success: true, message: await sent.fetch() };
930
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
931
931
  }
932
932
  else {
933
933
  const sent = await this.interaction.update(finalMessage);
934
934
  this.ignoreResponderTimeout = true;
935
- return { success: true, message: await sent.fetch() };
935
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
936
936
  }
937
937
  }
938
938
  catch {
@@ -1132,7 +1132,7 @@ export class ODModalResponderInstance extends ODBaseResponderInstance {
1132
1132
  const finalMessage = this.getMessageFromBuildResult(build, "interaction");
1133
1133
  const sent = await this.interaction.followUp(finalMessage);
1134
1134
  this.ignoreResponderTimeout = true;
1135
- return { success: true, message: sent };
1135
+ return { success: true, message: sent, ephemeral: build.ephemeral };
1136
1136
  }
1137
1137
  catch {
1138
1138
  return { success: false };
@@ -1145,12 +1145,12 @@ export class ODModalResponderInstance extends ODBaseResponderInstance {
1145
1145
  if (this.interaction.replied || this.interaction.deferred) {
1146
1146
  const sent = await this.interaction.editReply(finalMessage);
1147
1147
  this.ignoreResponderTimeout = true;
1148
- return { success: true, message: await sent.fetch() };
1148
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
1149
1149
  }
1150
1150
  else {
1151
1151
  const sent = await this.interaction.reply(finalMessage);
1152
1152
  this.ignoreResponderTimeout = true;
1153
- return { success: true, message: await sent.fetch() };
1153
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
1154
1154
  }
1155
1155
  }
1156
1156
  catch {
@@ -1296,12 +1296,12 @@ export class ODContextMenuResponderInstance extends ODBaseResponderInstance {
1296
1296
  if (this.interaction.replied || this.interaction.deferred) {
1297
1297
  const sent = await this.interaction.editReply(finalMessage);
1298
1298
  this.ignoreResponderTimeout = true;
1299
- return { success: true, message: sent };
1299
+ return { success: true, message: sent, ephemeral: build.ephemeral };
1300
1300
  }
1301
1301
  else {
1302
1302
  const sent = await this.interaction.reply(finalMessage);
1303
1303
  this.ignoreResponderTimeout = true;
1304
- return { success: true, message: await sent.fetch() };
1304
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
1305
1305
  }
1306
1306
  }
1307
1307
  catch {
@@ -1315,7 +1315,7 @@ export class ODContextMenuResponderInstance extends ODBaseResponderInstance {
1315
1315
  if (this.interaction.replied || this.interaction.deferred) {
1316
1316
  const sent = await this.interaction.editReply(finalMessage);
1317
1317
  this.ignoreResponderTimeout = true;
1318
- return { success: true, message: await sent.fetch() };
1318
+ return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
1319
1319
  }
1320
1320
  else
1321
1321
  throw new ODSystemError("Unable to update context menu interaction!");
@@ -182,7 +182,7 @@ export class ODStartScreenCategoryComponent extends ODStartScreenComponent {
182
182
  super(id, priority, async (location) => {
183
183
  const contents = await render(location);
184
184
  if (contents != "" || this.renderIfEmpty) {
185
- return ansis.bold.underline("\n" + name.toUpperCase() + (contents != "" ? ":\n" : ":")) + contents;
185
+ return ansis.bold.underline("\n" + this.name.toUpperCase() + (contents != "" ? ":\n" : ":")) + contents;
186
186
  }
187
187
  else
188
188
  return "";
@@ -265,7 +265,7 @@ export class ODStartScreenLiveStatusCategoryComponent extends ODStartScreenCateg
265
265
  /**A reference to the Open Discord livestatus manager. */
266
266
  livestatus;
267
267
  constructor(id, priority, livestatus) {
268
- super(id, priority, "livestatus", async () => {
268
+ super(id, priority, "news & updates", async () => {
269
269
  const messages = await this.livestatus.getAllMessages();
270
270
  return this.livestatus.renderer.render(messages);
271
271
  }, false);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-discord-bots/framework",
3
3
  "author": "DJj123dj",
4
- "version": "0.3.4",
4
+ "version": "0.3.5",
5
5
  "description": "The core framework of the popular open-source discord bots: Open Ticket & Open Moderation.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
package/src/api/main.ts CHANGED
@@ -154,7 +154,7 @@ export abstract class ODMain implements ODMainManagers {
154
154
  constructor(managers:ODMainManagers,project:ODProjectType){
155
155
  this.project = project
156
156
  this.versions = managers.versions
157
- this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.4"))
157
+ this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.5"))
158
158
  this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
159
159
 
160
160
  this.debugfile = managers.debugfile
@@ -332,14 +332,14 @@ export class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstrai
332
332
  if (user.bot) return {success:false}
333
333
  const channel = await user.createDM()
334
334
  const msg = await channel.send(finalMessage)
335
- return {success:true,message:msg}
335
+ return {success:true,message:msg,ephemeral:false}
336
336
  }else{
337
337
  const newUser = await this.fetchUser(user)
338
338
  if (!newUser) throw new Error()
339
339
  if (newUser.bot) return {success:false}
340
340
  const channel = await newUser.createDM()
341
341
  const msg = await channel.send(finalMessage)
342
- return {success:true,message:msg}
342
+ return {success:true,message:msg,ephemeral:false}
343
343
  }
344
344
  }catch{
345
345
  try{
@@ -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"}
@@ -111,7 +111,7 @@ export class ODPost<ChannelType extends discord.GuildBasedChannel> extends ODMan
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
116
  return {success:false}
117
117
  }
@@ -44,7 +44,9 @@ 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
52
  success:false
@@ -473,16 +475,16 @@ export class ODCommandResponderInstance extends ODBaseResponderInstance {
473
475
  if (this.interaction.replied || this.interaction.deferred){
474
476
  const sent = await this.interaction.editReply(finalMessage)
475
477
  this.ignoreResponderTimeout = true
476
- return {success:true,message:sent}
478
+ return {success:true,message:sent,ephemeral:build.ephemeral}
477
479
  }else{
478
480
  const sent = await this.interaction.reply(finalMessage)
479
481
  this.ignoreResponderTimeout = true
480
- return {success:true,message:await sent.fetch()}
482
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
481
483
  }
482
484
  }else if (this.type == "message" && this.interaction instanceof discord.Message && this.interaction.channel.type != discord.ChannelType.GroupDM){
483
485
  const sent = await this.interaction.channel.send(finalMessage)
484
486
  this.ignoreResponderTimeout = true
485
- return {success:true,message:sent}
487
+ return {success:true,message:sent,ephemeral:false}
486
488
  }else return {success:false}
487
489
  }catch{
488
490
  return {success:false}
@@ -661,11 +663,11 @@ export class ODButtonResponderInstance extends ODBaseResponderInstance {
661
663
  if (this.interaction.replied || this.interaction.deferred){
662
664
  const sent = await this.interaction.editReply(finalMessage)
663
665
  this.ignoreResponderTimeout = true
664
- return {success:true,message:sent}
666
+ return {success:true,message:sent,ephemeral:build.ephemeral}
665
667
  }else{
666
668
  const sent = await this.interaction.reply(finalMessage)
667
669
  this.ignoreResponderTimeout = true
668
- return {success:true,message:await sent.fetch()}
670
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
669
671
  }
670
672
  }catch{
671
673
  return {success:false}
@@ -678,11 +680,11 @@ export class ODButtonResponderInstance extends ODBaseResponderInstance {
678
680
  if (this.interaction.replied || this.interaction.deferred){
679
681
  const sent = await this.interaction.editReply(finalMessage)
680
682
  this.ignoreResponderTimeout = true
681
- return {success:true,message:await sent.fetch()}
683
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
682
684
  }else{
683
685
  const sent = await this.interaction.update(finalMessage)
684
686
  this.ignoreResponderTimeout = true
685
- return {success:true,message:await sent.fetch()}
687
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
686
688
  }
687
689
  }catch{
688
690
  return {success:false}
@@ -976,11 +978,11 @@ export class ODDropdownResponderInstance extends ODBaseResponderInstance {
976
978
  if (this.interaction.replied || this.interaction.deferred){
977
979
  const sent = await this.interaction.editReply(finalMessage)
978
980
  this.ignoreResponderTimeout = true
979
- return {success:true,message:sent}
981
+ return {success:true,message:sent,ephemeral:build.ephemeral}
980
982
  }else{
981
983
  const sent = await this.interaction.reply(finalMessage)
982
984
  this.ignoreResponderTimeout = true
983
- return {success:true,message:await sent.fetch()}
985
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
984
986
  }
985
987
  }catch{
986
988
  return {success:false}
@@ -993,11 +995,11 @@ export class ODDropdownResponderInstance extends ODBaseResponderInstance {
993
995
  if (this.interaction.replied || this.interaction.deferred){
994
996
  const sent = await this.interaction.editReply(finalMessage)
995
997
  this.ignoreResponderTimeout = true
996
- return {success:true,message:await sent.fetch()}
998
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
997
999
  }else{
998
1000
  const sent = await this.interaction.update(finalMessage)
999
1001
  this.ignoreResponderTimeout = true
1000
- return {success:true,message:await sent.fetch()}
1002
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
1001
1003
  }
1002
1004
  }catch{
1003
1005
  return {success:false}
@@ -1225,7 +1227,7 @@ export class ODModalResponderInstance extends ODBaseResponderInstance {
1225
1227
  const finalMessage = this.getMessageFromBuildResult(build,"interaction")
1226
1228
  const sent = await this.interaction.followUp(finalMessage)
1227
1229
  this.ignoreResponderTimeout = true
1228
- return {success:true,message:sent}
1230
+ return {success:true,message:sent,ephemeral:build.ephemeral}
1229
1231
  }catch{
1230
1232
  return {success:false}
1231
1233
  }
@@ -1237,11 +1239,11 @@ export class ODModalResponderInstance extends ODBaseResponderInstance {
1237
1239
  if (this.interaction.replied || this.interaction.deferred){
1238
1240
  const sent = await this.interaction.editReply(finalMessage)
1239
1241
  this.ignoreResponderTimeout = true
1240
- return {success:true,message:await sent.fetch()}
1242
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
1241
1243
  }else{
1242
1244
  const sent = await this.interaction.reply(finalMessage)
1243
1245
  this.ignoreResponderTimeout = true
1244
- return {success:true,message:await sent.fetch()}
1246
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
1245
1247
  }
1246
1248
  }catch{
1247
1249
  return {success:false}
@@ -1405,11 +1407,11 @@ export class ODContextMenuResponderInstance extends ODBaseResponderInstance {
1405
1407
  if (this.interaction.replied || this.interaction.deferred){
1406
1408
  const sent = await this.interaction.editReply(finalMessage)
1407
1409
  this.ignoreResponderTimeout = true
1408
- return {success:true,message:sent}
1410
+ return {success:true,message:sent,ephemeral:build.ephemeral}
1409
1411
  }else{
1410
1412
  const sent = await this.interaction.reply(finalMessage)
1411
1413
  this.ignoreResponderTimeout = true
1412
- return {success:true,message:await sent.fetch()}
1414
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
1413
1415
  }
1414
1416
  }catch{
1415
1417
  return {success:false}
@@ -1422,7 +1424,7 @@ export class ODContextMenuResponderInstance extends ODBaseResponderInstance {
1422
1424
  if (this.interaction.replied || this.interaction.deferred){
1423
1425
  const sent = await this.interaction.editReply(finalMessage)
1424
1426
  this.ignoreResponderTimeout = true
1425
- return {success:true,message:await sent.fetch()}
1427
+ return {success:true,message:await sent.fetch(),ephemeral:build.ephemeral}
1426
1428
  }else throw new ODSystemError("Unable to update context menu interaction!")
1427
1429
  }catch{
1428
1430
  return {success:false}
@@ -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,"livestatus",async () => {
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)