trivious 1.5.2 → 1.5.3

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/README.md CHANGED
@@ -47,28 +47,47 @@ const client = new TriviousClient({
47
47
  ### Creating a Slash Command
48
48
  ```ts
49
49
  // src/core/commands/debug/index.ts
50
- import { CommandBuilder, Command, PermissionLevel } from "trivious";
51
-
52
- const { data, metadata } = new CommandBuilder()
53
- .setName("debug")
54
- .setDescription("Debugging tools")
55
- .setGuildOnly()
56
- .setPermission(PermissionLevel.GUILD_ADMINISTRATOR)
57
- .setEphemeralReply()
58
- .build();
59
-
60
- export default class DebugCommand extends Command {
61
- data = data;
62
- metadata = metadata;
63
-
64
- // Optional: run when no subcommand is used
65
- async run?(client, interaction) {
66
- await this.reply(interaction, { content: "Use a subcommand!" });
67
- }
68
- }
50
+ import { CommandBuilder, SlashCommand } from "trivious"
51
+
52
+ export default class DebugCommand extends SlashCommand {
53
+ constructor() {
54
+ super(new CommandBuilder()
55
+ .setName("debug")
56
+ .setDescription("Debug tools")
57
+ .setGuildOnly()
58
+ .setEphemeralReply())
59
+ }
60
+ };
69
61
  ```
70
62
  > Subcommands go in the same directory as the command file and are auto-detected.
71
63
 
64
+ ### Creating a Subcommand
65
+ ```ts
66
+ // src/core/commands/debug/ping.ts
67
+ import { ChatInputCommandInteraction, Subcommand, SubcommandBuilder, TriviousClient } from "trivious";
68
+
69
+ export default class DebugPingSubcommand extends Subcommand {
70
+ constructor() {
71
+ super(new SubcommandBuilder()
72
+ .setName("ping")
73
+ .setDescription("Ping pong!")
74
+ .setOwnerOnly())
75
+ }
76
+
77
+ execute = async (client: TriviousClient, interaction: ChatInputCommandInteraction) => {
78
+ try {
79
+ const sent = await interaction.fetchReply();
80
+ const latency = sent.createdTimestamp - interaction.createdTimestamp;
81
+ const apiLatency = Math.round(interaction.client.ws.ping);
82
+
83
+ await this.reply(interaction, { content: `Pong!\nLatency ${latency}ms API Latency: ${apiLatency}ms` });
84
+ } catch (error: any) {
85
+ console.error(error);
86
+ }
87
+ };
88
+ };
89
+ ```
90
+
72
91
  ---
73
92
 
74
93
  ### Permission Levels
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/builders/util.builders.ts"],"names":["ActionRowBuilder","EmbedBuilder"],"mappings":";;;;AAEO,SAAS,mBAA+D,QAAA,EAAe;AAC7F,EAAA,OAAO,IAAIA,2BAAA,EAAoB,CAAE,aAAA,CAAc,GAAG,QAAQ,CAAA;AAC3D;AAEO,SAAS,YAAY,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAIC,wBAAa,IAAI,CAAA;AAC7B","file":"util.builders.cjs","sourcesContent":["import { ActionRowBuilder, APIEmbed, EmbedBuilder, EmbedData, MessageActionRowComponentBuilder } from \"discord.js\";\n\nexport function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]) {\n\treturn new ActionRowBuilder<T>().setComponents(...builders);\n}\n\nexport function createEmbed(data?: EmbedData | APIEmbed) {\n\treturn new EmbedBuilder(data);\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/builders/util.builders.ts"],"names":["ActionRowBuilder","EmbedBuilder"],"mappings":";;;;AAUO,SAAS,mBAA+D,QAAA,EAAe;AAC7F,EAAA,OAAO,IAAIA,2BAAA,EAAoB,CAAE,aAAA,CAAc,GAAG,QAAQ,CAAA;AAC3D;AASO,SAAS,YAAY,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAIC,wBAAa,IAAI,CAAA;AAC7B","file":"util.builders.cjs","sourcesContent":["import { ActionRowBuilder, APIEmbed, EmbedBuilder, EmbedData, MessageActionRowComponentBuilder } from \"discord.js\";\n\n/**\n * Utility action row builder\n *\n * @export\n * @template {MessageActionRowComponentBuilder} T\n * @param {...T[]} builders\n * @returns {*}\n */\nexport function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]) {\n\treturn new ActionRowBuilder<T>().setComponents(...builders);\n}\n\n/**\n * Utility embed builder\n *\n * @export\n * @param {?(EmbedData | APIEmbed)} [data]\n * @returns {*}\n */\nexport function createEmbed(data?: EmbedData | APIEmbed) {\n\treturn new EmbedBuilder(data);\n}\n"]}
@@ -1,6 +1,21 @@
1
1
  import { MessageActionRowComponentBuilder, ActionRowBuilder, EmbedData, APIEmbed, EmbedBuilder } from 'discord.js';
2
2
 
3
+ /**
4
+ * Utility action row builder
5
+ *
6
+ * @export
7
+ * @template {MessageActionRowComponentBuilder} T
8
+ * @param {...T[]} builders
9
+ * @returns {*}
10
+ */
3
11
  declare function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]): ActionRowBuilder<T>;
12
+ /**
13
+ * Utility embed builder
14
+ *
15
+ * @export
16
+ * @param {?(EmbedData | APIEmbed)} [data]
17
+ * @returns {*}
18
+ */
4
19
  declare function createEmbed(data?: EmbedData | APIEmbed): EmbedBuilder;
5
20
 
6
21
  export { createActionRow, createEmbed };
@@ -1,6 +1,21 @@
1
1
  import { MessageActionRowComponentBuilder, ActionRowBuilder, EmbedData, APIEmbed, EmbedBuilder } from 'discord.js';
2
2
 
3
+ /**
4
+ * Utility action row builder
5
+ *
6
+ * @export
7
+ * @template {MessageActionRowComponentBuilder} T
8
+ * @param {...T[]} builders
9
+ * @returns {*}
10
+ */
3
11
  declare function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]): ActionRowBuilder<T>;
12
+ /**
13
+ * Utility embed builder
14
+ *
15
+ * @export
16
+ * @param {?(EmbedData | APIEmbed)} [data]
17
+ * @returns {*}
18
+ */
4
19
  declare function createEmbed(data?: EmbedData | APIEmbed): EmbedBuilder;
5
20
 
6
21
  export { createActionRow, createEmbed };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/builders/util.builders.ts"],"names":[],"mappings":";;AAEO,SAAS,mBAA+D,QAAA,EAAe;AAC7F,EAAA,OAAO,IAAI,gBAAA,EAAoB,CAAE,aAAA,CAAc,GAAG,QAAQ,CAAA;AAC3D;AAEO,SAAS,YAAY,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAI,aAAa,IAAI,CAAA;AAC7B","file":"util.builders.js","sourcesContent":["import { ActionRowBuilder, APIEmbed, EmbedBuilder, EmbedData, MessageActionRowComponentBuilder } from \"discord.js\";\n\nexport function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]) {\n\treturn new ActionRowBuilder<T>().setComponents(...builders);\n}\n\nexport function createEmbed(data?: EmbedData | APIEmbed) {\n\treturn new EmbedBuilder(data);\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/builders/util.builders.ts"],"names":[],"mappings":";;AAUO,SAAS,mBAA+D,QAAA,EAAe;AAC7F,EAAA,OAAO,IAAI,gBAAA,EAAoB,CAAE,aAAA,CAAc,GAAG,QAAQ,CAAA;AAC3D;AASO,SAAS,YAAY,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAI,aAAa,IAAI,CAAA;AAC7B","file":"util.builders.js","sourcesContent":["import { ActionRowBuilder, APIEmbed, EmbedBuilder, EmbedData, MessageActionRowComponentBuilder } from \"discord.js\";\n\n/**\n * Utility action row builder\n *\n * @export\n * @template {MessageActionRowComponentBuilder} T\n * @param {...T[]} builders\n * @returns {*}\n */\nexport function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]) {\n\treturn new ActionRowBuilder<T>().setComponents(...builders);\n}\n\n/**\n * Utility embed builder\n *\n * @export\n * @param {?(EmbedData | APIEmbed)} [data]\n * @returns {*}\n */\nexport function createEmbed(data?: EmbedData | APIEmbed) {\n\treturn new EmbedBuilder(data);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trivious",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "discord-bot",