@elara-services/tickets 4.0.0 → 4.0.2

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/index.d.ts CHANGED
@@ -1,28 +1,28 @@
1
1
  declare module "@elara-services/tickets" {
2
2
 
3
- import { Client, MessageOptions, GuildMember, Guild, User, TextBasedChannel, Message, Interaction } from "discord.js";
3
+ import type { Client, MessageOptions, GuildMember, Guild, User, TextBasedChannel, Message, Interaction } from "discord.js";
4
4
 
5
- type Langs = "en-US";
5
+ export type Langs = "en-US";
6
6
 
7
7
  export interface TicketOptions {
8
8
  client: Client;
9
9
  prefix: string;
10
- lang?: Langs;
11
- debug?: boolean;
12
10
  encryptToken: string;
11
+ lang?: Langs;
12
+ debug?: boolean;
13
13
  appeals?: {
14
- enabled: boolean;
14
+ enabled?: boolean;
15
15
  sendBanResults?: boolean;
16
16
  mainserver: {
17
17
  id: string;
18
- checkIfBanned: boolean;
18
+ checkIfBanned?: boolean;
19
19
  };
20
20
  embeds?: {
21
21
  not_banned: Pick<MessageOptions, "content" | "embeds" | "components">
22
22
  }
23
23
  };
24
24
  modal?: {
25
- enabled: boolean;
25
+ enabled?: boolean;
26
26
  title?: string;
27
27
  questions?: {
28
28
  label: string;
@@ -144,6 +144,7 @@ declare module "@elara-services/tickets" {
144
144
  }): Promise<unknown>;
145
145
 
146
146
  public run(int: Interaction): Promise<unknown>;
147
+ public runMany(interaction: Interaction, tickets: Tickets[]): this;
147
148
  public starterMessage(channelId: string, options?: Pick<MessageOptions, "embeds" | "content" | "components" | "attachments">): Promise<unknown>;
148
149
  };
149
150
 
package/index.js CHANGED
@@ -6,14 +6,8 @@ module.exports = (() => {
6
6
  throw new Error(`[${pack.name}, v${pack.version}]: I was unable to find the discord.js version you're using.`);
7
7
  }
8
8
  let [major] = version.split(".");
9
- if (major === "14") {
10
- return require("./lib/v14");
11
- }
12
- if (major === "13") {
13
- return require("./lib/v13");
14
- }
15
- if (["12", "11"].includes(major)) {
16
- throw new Error(`[${pack.name}, v${pack.version}]: The discord.js version you're using is outdated and unsupported, please update to v13+`);
9
+ if (["13", "14"].includes(major)) {
10
+ return require(`./lib/v${major}`);
17
11
  }
18
12
  throw new Error(`[${pack.name}, v${pack.version}]: The discord.js version you're using isn't supported by this package. (currently supported: v13, v14)`);
19
13
  })();
package/lib/base.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const { getWebhookInfo, displayMessages, de, webhook, getString } = require("./util");
2
2
  const {
3
- Interactions: { button, modal },
3
+ Interactions: { button },
4
4
  } = require("@elara-services/packages");
5
5
  const { is } = require("@elara-services/utils");
6
6
  const { WebhookClient } = require("discord.js");
@@ -21,18 +21,36 @@ module.exports = class Tickets {
21
21
  }
22
22
  this.options = options;
23
23
  }
24
+
24
25
  get prefix() {
25
26
  return `system:ticket:${this.options.prefix}`;
26
27
  }
28
+
27
29
  get webhookOptions() {
28
30
  return getWebhookInfo(this.options, this.str("TICKETS"));
29
31
  }
32
+
30
33
  get getSupportIds() {
31
34
  return {
32
35
  roles: this.options.support?.roles || [],
33
36
  users: this.options.support?.users || [],
34
37
  };
35
38
  }
39
+
40
+ /**
41
+ * @param {import("discord.js").Interaction} interation
42
+ * @param {Tickets[]} tickets
43
+ */
44
+ runMany(interation, tickets = []) {
45
+ if (!interation || !is.array(tickets)) {
46
+ return this;
47
+ }
48
+ for (const ticket of tickets) {
49
+ ticket.run(interation);
50
+ }
51
+ return this;
52
+ }
53
+
36
54
  /**
37
55
  * @param {keyof typeof import("../languages/en-US")} name
38
56
  */
@@ -62,39 +80,6 @@ module.exports = class Tickets {
62
80
  emoji: options.emoji,
63
81
  });
64
82
  }
65
-
66
- /**
67
- * @param {object} options
68
- * @param {string} [options.title] The title of the modal submit form
69
- * @param {import("@elara-services/packages").Modal['components']} [options.components]
70
- */
71
- modal(options = { title: "", components: [] }) {
72
- return modal({
73
- id: `${this.prefix}:modal_submit`,
74
- title: options?.title || this.str("CREATE_TICKET"),
75
- components:
76
- options?.components?.length >= 1
77
- ? options.components
78
- : [
79
- {
80
- type: 1,
81
- components: [
82
- {
83
- type: 4,
84
- min_length: 10,
85
- max_length: 4000,
86
- custom_id: "message",
87
- label: this.str("MODAL_CONTENT"),
88
- style: 2,
89
- placeholder: this.str("MODAL_CONTENT_PLACEHOLDER"),
90
- required: true,
91
- },
92
- ],
93
- },
94
- ],
95
- });
96
- }
97
-
98
83
  async closeTicket({ member, messages, channel, guild, user, reason } = {}) {
99
84
  const { id, token, username, avatar: avatarURL, threadId } = this.webhookOptions;
100
85
  if (!id || !token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elara-services/tickets",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Helper for tickets",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",