@elara-services/tickets 2.0.4 → 2.1.0
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 +1 -0
- package/index.d.ts +2 -1
- package/index.js +15 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ const { Client } = require("discord.js"),
|
|
|
51
51
|
avatar: "", // 'webhookAvatar' support will be removed in the next major version
|
|
52
52
|
},
|
|
53
53
|
support: {
|
|
54
|
+
canOnlyCloseTickets: true, // If 'true' only roles and users listed below can close tickets. (OR people with 'Manage Server' permission)
|
|
54
55
|
roles: [ // 'supportRoleIds' support will be removed in the next major version
|
|
55
56
|
"123456789"
|
|
56
57
|
],
|
package/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare module "@elara-services/tickets" {
|
|
|
12
12
|
ticketOpen?: Pick<MessageOptions, "content" | "embeds">
|
|
13
13
|
appeals?: {
|
|
14
14
|
enabled: boolean;
|
|
15
|
-
|
|
15
|
+
mainserver: {
|
|
16
16
|
id: string;
|
|
17
17
|
checkIfBanned: boolean;
|
|
18
18
|
};
|
|
@@ -42,6 +42,7 @@ declare module "@elara-services/tickets" {
|
|
|
42
42
|
support?: {
|
|
43
43
|
roles?: string[];
|
|
44
44
|
users?: string[];
|
|
45
|
+
canOnlyCloseTickets?: boolean;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
/** @deprecated Use 'webhook.id' */
|
package/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const { Collection, WebhookClient, MessageEmbed } = require("discord.js"),
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
module.exports = class Tickets {
|
|
13
|
-
constructor(options) {
|
|
13
|
+
constructor(options = {}) {
|
|
14
14
|
if (typeof options !== "object") throw new Error(`You didn't provide any data in the constructor, fill it out!`);
|
|
15
15
|
if (!("client" in options) || !("prefix" in options) || !("encryptToken" in options)) throw new Error(`You forgot to fill out either 'client', 'prefix' or 'encryptToken'`)
|
|
16
16
|
this.options = options;
|
|
@@ -64,7 +64,20 @@ module.exports = class Tickets {
|
|
|
64
64
|
return this.handleCreate({ guild, member, category, send })
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
case `${this.prefix}:close`:
|
|
67
|
+
case `${this.prefix}:close`: {
|
|
68
|
+
if (this.options.support?.canOnlyCloseTickets && !member.permissions.has("MANAGE_GUILD")) {
|
|
69
|
+
let [ support, staffOnly ] = [
|
|
70
|
+
this.getSupportIds(),
|
|
71
|
+
() => send({
|
|
72
|
+
ephemeral: true,
|
|
73
|
+
embeds: [ { author: { name: `Only support staff can close tickets`, iconURL: "https://cdn.discordapp.com/emojis/781955502035697745.gif" }, color: 0xFF0000 } ]
|
|
74
|
+
})
|
|
75
|
+
];
|
|
76
|
+
if (!support.users?.includes?.(member.id)) return staffOnly();
|
|
77
|
+
if (support.roles?.length && !support.roles.some(c => member.roles.cache.has(c))) return staffOnly()
|
|
78
|
+
}
|
|
79
|
+
return send({ ephemeral: true, content: `🤔 Are you sure you want to close this ticket?`, components: [{ type: 1, components: [{ type: 2, custom_id: `${this.prefix}:close:confirm:${this.code(channel.topic?.split?.("ID: ")?.[1])}`, label: "Yes close the ticket", style: 4, emoji: { id: "807031399563264030" } }] }] })
|
|
80
|
+
}
|
|
68
81
|
|
|
69
82
|
case `${this.prefix}:modal_submit`: {
|
|
70
83
|
let [embed, fields, split] = [new MessageEmbed().setColor("ORANGE"), [], false];
|