@elara-services/tickets 4.0.0 → 4.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/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;
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,38 @@ 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
+ *
42
+ * @param {import("discord.js").Interaction} interation
43
+ * @param {Tickets[]} tickets
44
+ * @returns
45
+ */
46
+ runMultiple(interation, tickets = []) {
47
+ if (!interation || !is.array(tickets)) {
48
+ return this;
49
+ }
50
+ for (const ticket of tickets) {
51
+ ticket.run(interation);
52
+ }
53
+ return this;
54
+ }
55
+
36
56
  /**
37
57
  * @param {keyof typeof import("../languages/en-US")} name
38
58
  */
@@ -62,39 +82,6 @@ module.exports = class Tickets {
62
82
  emoji: options.emoji,
63
83
  });
64
84
  }
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
85
  async closeTicket({ member, messages, channel, guild, user, reason } = {}) {
99
86
  const { id, token, username, avatar: avatarURL, threadId } = this.webhookOptions;
100
87
  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.1",
4
4
  "description": "Helper for tickets",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",