@elara-services/tickets 2.0.2 → 2.0.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/index.js +12 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -45,9 +45,9 @@ module.exports = class Tickets {
|
|
|
45
45
|
* @param {boolean} defer
|
|
46
46
|
*/
|
|
47
47
|
const send = async (options = {}, defer = false) => {
|
|
48
|
-
if (defer) return int.deferReply(options).catch(this._debug);
|
|
49
|
-
if (int.replied || int.deferred) return int.editReply(options).catch(this._debug);
|
|
50
|
-
return int.reply(options).catch(this._debug);
|
|
48
|
+
if (defer) return int.deferReply(options).catch(e => this._debug(e));
|
|
49
|
+
if (int.replied || int.deferred) return int.editReply(options).catch(e => this._debug(e));
|
|
50
|
+
return int.reply(options).catch(e => this._debug(e));
|
|
51
51
|
};
|
|
52
52
|
switch (customId) {
|
|
53
53
|
case this.prefix: {
|
|
@@ -57,7 +57,7 @@ module.exports = class Tickets {
|
|
|
57
57
|
components: this.options.modal.questions?.length >= 1 ?
|
|
58
58
|
this.options.modal.questions.slice(0, 5).map(c => ({ type: 1, components: [{ min_length: c.min_length || 10, max_length: c.max_length || 4000, type: 4, style: c.style || 2, label: c.label, value: c.value, placeholder: c.placeholder, required: c.required, custom_id: c.label || `random_${Math.floor(Math.random() * 10000)}` }] })) :
|
|
59
59
|
[]
|
|
60
|
-
})).catch(this._debug);
|
|
60
|
+
})).catch(e => this._debug(e));
|
|
61
61
|
}
|
|
62
62
|
return this.handleCreate({ guild, member, category, send })
|
|
63
63
|
};
|
|
@@ -100,7 +100,7 @@ module.exports = class Tickets {
|
|
|
100
100
|
if (!user) return send({ content: `❌ I was unable to fetch the user that opened the ticket.`, ephemeral: true })
|
|
101
101
|
let messages = await this.fetchMessages(channel, 5000);
|
|
102
102
|
if (!messages || !messages.length) return send({ ephemeral: true, content: `❌ I was unable to close the ticket, I couldn't fetch the messages in this channel.` })
|
|
103
|
-
let closed = await channel.delete(`${member.user.tag} (${member.id}) closed the ticket.`).catch(this._debug);
|
|
103
|
+
let closed = await channel.delete(`${member.user.tag} (${member.id}) closed the ticket.`).catch(e => this._debug(e));
|
|
104
104
|
if (!closed) return send({ ephemeral: true, content: `${emojis.x} I was unable to delete the channel & close the ticket.` })
|
|
105
105
|
return this.closeTicket({ channel, guild, user, member, messages });
|
|
106
106
|
}
|
|
@@ -164,7 +164,7 @@ module.exports = class Tickets {
|
|
|
164
164
|
{ type: "role", id: guild.id, deny: ["VIEW_CHANNEL"] },
|
|
165
165
|
...permissions
|
|
166
166
|
]
|
|
167
|
-
}).catch(this._debug);
|
|
167
|
+
}).catch(e => this._debug(e));
|
|
168
168
|
if (!channel) return send({ content: `${emojis.x} I was unable to create the ticket channel, if this keeps happening contact one of the staff members via their DMs!` });
|
|
169
169
|
let msg = await channel.send({
|
|
170
170
|
content: this.options.ticketOpen?.content?.replace?.(/%user%/gi, member.user.toString())?.replace?.(/%server%/gi, guild.name) || `${member.user.toString()} 👋 Hello, please explain what you need help with.`,
|
|
@@ -176,9 +176,9 @@ module.exports = class Tickets {
|
|
|
176
176
|
footer: { text: `To close this ticket press the button below.` }
|
|
177
177
|
}],
|
|
178
178
|
components: [{ type: 1, components: [{ type: 2, custom_id: `${this.prefix}:close`, label: "Close Ticket", style: 4, emoji: { name: "🔒" } }] }]
|
|
179
|
-
}).catch(this._debug);
|
|
179
|
+
}).catch(e => this._debug(e));
|
|
180
180
|
if (!msg) return null;
|
|
181
|
-
if (embeds?.length <= 10) for await (const embed of embeds) await channel.send({ embeds: [ embed ] }).catch(this._debug);
|
|
181
|
+
if (embeds?.length <= 10) for await (const embed of embeds) await channel.send({ embeds: [ embed ] }).catch(e => this._debug(e));
|
|
182
182
|
if (this.webhookOptions.id && this.webhookOptions.token) this.webhook()
|
|
183
183
|
.embed({
|
|
184
184
|
author: { name: guild.name, icon_url: guild.iconURL({ dynamic: true }) },
|
|
@@ -187,7 +187,7 @@ module.exports = class Tickets {
|
|
|
187
187
|
color: 0xFF000,
|
|
188
188
|
timestamp: new Date(),
|
|
189
189
|
footer: { text: `Ticket ID: ${channel.name.split("-")[1]}` },
|
|
190
|
-
}).send().catch(this._debug);
|
|
190
|
+
}).send().catch(e => this._debug(e));
|
|
191
191
|
return send({
|
|
192
192
|
embeds: [
|
|
193
193
|
{
|
|
@@ -365,7 +365,7 @@ module.exports = class Tickets {
|
|
|
365
365
|
.embeds(embeds)
|
|
366
366
|
.button({ type: 1, components })
|
|
367
367
|
.edit(m.id)
|
|
368
|
-
.catch(this._debug);
|
|
368
|
+
.catch(e => this._debug(e));
|
|
369
369
|
if (user) user.send({
|
|
370
370
|
embeds: [{
|
|
371
371
|
author: { name: guild.name, icon_url: guild.iconURL({ dynamic: true }) },
|
|
@@ -375,8 +375,8 @@ module.exports = class Tickets {
|
|
|
375
375
|
footer: { text: `Ticket ID: ${channel.name.split("-")[1]}` }
|
|
376
376
|
}],
|
|
377
377
|
components: [{ type: 1, components }]
|
|
378
|
-
}).catch(this._debug);
|
|
379
|
-
}).catch(this._debug);
|
|
378
|
+
}).catch(e => this._debug(e));
|
|
379
|
+
}).catch(e => this._debug(e));
|
|
380
380
|
};
|
|
381
381
|
/**
|
|
382
382
|
* @typedef {Object} getSupportResponse
|