@elara-services/tickets 4.2.0 → 4.3.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/index.js +4 -0
- package/lib/v13.js +27 -7
- package/lib/v14.js +38 -9
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { emitPackageMessage, log } = require("@elara-services/utils");
|
|
1
2
|
const pack = require("./package.json");
|
|
2
3
|
const { version } = require("discord.js");
|
|
3
4
|
|
|
@@ -7,6 +8,9 @@ module.exports = (() => {
|
|
|
7
8
|
}
|
|
8
9
|
let [major] = version.split(".");
|
|
9
10
|
if (["13", "14"].includes(major)) {
|
|
11
|
+
emitPackageMessage(`${pack.name} - thanks`, () => {
|
|
12
|
+
log(`[${pack.name}, v${pack.version}]: Thanks for using the package!`, `Please support the packages via ${pack.funding.map((c) => c.url).join(" OR ")}`);
|
|
13
|
+
});
|
|
10
14
|
return require(`./lib/v${major}`);
|
|
11
15
|
}
|
|
12
16
|
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)`);
|
package/lib/v13.js
CHANGED
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
} = require("discord.js"),
|
|
6
6
|
base = require("./base"),
|
|
7
7
|
{ de, code, fetchMessages, hasTicket, embed, webhook, getAppealServer, perms, defs } = require("./util"),
|
|
8
|
-
{ generate, parser, discord } = require("@elara-services/utils"),
|
|
8
|
+
{ generate, parser, discord, is } = require("@elara-services/utils"),
|
|
9
9
|
{
|
|
10
10
|
Interactions: { button },
|
|
11
11
|
} = require("@elara-services/packages");
|
|
@@ -114,9 +114,25 @@ module.exports = class Tickets extends base {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
const hasEmbeds = this.options.ticket?.close?.confirm?.embeds;
|
|
117
118
|
let embs = await Promise.all(
|
|
118
|
-
(
|
|
119
|
-
|
|
119
|
+
(hasEmbeds.length
|
|
120
|
+
? hasEmbeds
|
|
121
|
+
: [
|
|
122
|
+
embed(undefined, {
|
|
123
|
+
description: this.str("TICKET_CLOSE_CONFIRM"),
|
|
124
|
+
title: `INFO`,
|
|
125
|
+
color: 0xff000,
|
|
126
|
+
guild,
|
|
127
|
+
str: (name) => this.str(name, this?.options?.lang),
|
|
128
|
+
}),
|
|
129
|
+
]
|
|
130
|
+
).map((c) => parser(c, { guild, member, user: member.user })),
|
|
131
|
+
);
|
|
132
|
+
const content = this.options.ticket?.close?.confirm?.content || ``;
|
|
133
|
+
if (!is.array(embs) && !is.string(content)) {
|
|
134
|
+
embs = [
|
|
135
|
+
await parser(
|
|
120
136
|
embed(undefined, {
|
|
121
137
|
description: this.str("TICKET_CLOSE_CONFIRM"),
|
|
122
138
|
title: `INFO`,
|
|
@@ -124,10 +140,14 @@ module.exports = class Tickets extends base {
|
|
|
124
140
|
guild,
|
|
125
141
|
str: (name) => this.str(name, this?.options?.lang),
|
|
126
142
|
}),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
{
|
|
144
|
+
guild,
|
|
145
|
+
member,
|
|
146
|
+
user: member.user,
|
|
147
|
+
},
|
|
148
|
+
),
|
|
149
|
+
];
|
|
150
|
+
}
|
|
131
151
|
return send({
|
|
132
152
|
ephemeral: true,
|
|
133
153
|
content,
|
package/lib/v14.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { EmbedBuilder: MessageEmbed, InteractionType, ChannelType, ComponentType } = require("discord.js"),
|
|
2
2
|
base = require("./base"),
|
|
3
3
|
{ de, code, fetchMessages, hasTicket, embed, webhook, getAppealServer, perms, defs } = require("./util"),
|
|
4
|
-
{ generate, parser, discord } = require("@elara-services/utils"),
|
|
4
|
+
{ generate, parser, discord, is } = require("@elara-services/utils"),
|
|
5
5
|
{
|
|
6
6
|
Interactions: { button },
|
|
7
7
|
} = require("@elara-services/packages");
|
|
@@ -110,15 +110,44 @@ module.exports = class Tickets extends base {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
const hasEmbeds = this.options.ticket?.close?.confirm?.embeds;
|
|
114
|
+
let embs = await Promise.all(
|
|
115
|
+
(hasEmbeds.length
|
|
116
|
+
? hasEmbeds
|
|
117
|
+
: [
|
|
118
|
+
embed(undefined, {
|
|
119
|
+
description: this.str("TICKET_CLOSE_CONFIRM"),
|
|
120
|
+
title: `INFO`,
|
|
121
|
+
color: 0xff000,
|
|
122
|
+
guild,
|
|
123
|
+
str: (name) => this.str(name, this?.options?.lang),
|
|
124
|
+
}),
|
|
125
|
+
]
|
|
126
|
+
).map((c) => parser(c, { guild, member, user: member.user })),
|
|
127
|
+
);
|
|
128
|
+
const content = this.options.ticket?.close?.confirm?.content || ``;
|
|
129
|
+
if (!is.array(embs) && !is.string(content)) {
|
|
130
|
+
embs = [
|
|
131
|
+
await parser(
|
|
132
|
+
embed(undefined, {
|
|
133
|
+
description: this.str("TICKET_CLOSE_CONFIRM"),
|
|
134
|
+
title: `INFO`,
|
|
135
|
+
color: 0xff000,
|
|
136
|
+
guild,
|
|
137
|
+
str: (name) => this.str(name, this?.options?.lang),
|
|
138
|
+
}),
|
|
139
|
+
{
|
|
140
|
+
guild,
|
|
141
|
+
member,
|
|
142
|
+
user: member.user,
|
|
143
|
+
},
|
|
144
|
+
),
|
|
145
|
+
];
|
|
146
|
+
}
|
|
113
147
|
return send({
|
|
114
148
|
ephemeral: true,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
color: 0xff000,
|
|
118
|
-
guild,
|
|
119
|
-
str: (name) => this.str(name, this?.options?.lang),
|
|
120
|
-
}),
|
|
121
|
-
],
|
|
149
|
+
content,
|
|
150
|
+
embeds: [embs],
|
|
122
151
|
components: [
|
|
123
152
|
{
|
|
124
153
|
type: 1,
|
|
@@ -127,7 +156,7 @@ module.exports = class Tickets extends base {
|
|
|
127
156
|
title: this.str("TICKET_CLOSE_CONFIRM_BUTTON"),
|
|
128
157
|
style: 3,
|
|
129
158
|
emoji: { id: "807031399563264030" },
|
|
130
|
-
id: `${this.prefix}:close:confirm:${code(channel.topic?.split?.(
|
|
159
|
+
id: `${this.prefix}:close:confirm:${code(channel.topic?.split?.("ID: ")?.[1], "d", this.options.encryptToken)}${this.options?.ticket?.closeReason ? `:modal_submit` : ""}`,
|
|
131
160
|
}),
|
|
132
161
|
],
|
|
133
162
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elara-services/tickets",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Helper for tickets",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@elara-services/packages": "^6.0.9",
|
|
31
|
-
"@elara-services/utils": "^1.
|
|
31
|
+
"@elara-services/utils": "^1.4.0",
|
|
32
32
|
"@elara-services/webhooks": "^2.1.18"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|