mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-01-10 18:06:27 +02:00
fix: custom ID overflow with Create from message
(closes #494)
This commit is contained in:
parent
f9a7f0cbd9
commit
b0d77c1af6
@ -18,6 +18,6 @@ module.exports = class CreateMessageCommand extends MessageCommand {
|
||||
* @param {import("discord.js").MessageContextMenuCommandInteraction} interaction
|
||||
*/
|
||||
async run(interaction) {
|
||||
await useGuild(this.client, interaction, { referencesMessage: interaction.targetMessage.channelId + '/' + interaction.targetId });
|
||||
await useGuild(this.client, interaction, { referencesMessageId: interaction.targetId });
|
||||
}
|
||||
};
|
@ -155,7 +155,7 @@ module.exports = class TicketManager {
|
||||
* @param {string?} [data.topic]
|
||||
*/
|
||||
async create({
|
||||
categoryId, interaction, topic, referencesMessage, referencesTicketId,
|
||||
categoryId, interaction, topic, referencesMessageId, referencesTicketId,
|
||||
}) {
|
||||
categoryId = Number(categoryId);
|
||||
const category = await this.getCategory(categoryId);
|
||||
@ -276,7 +276,7 @@ module.exports = class TicketManager {
|
||||
.setCustomId(JSON.stringify({
|
||||
action: 'questions',
|
||||
categoryId,
|
||||
referencesMessage,
|
||||
referencesMessageId,
|
||||
referencesTicketId,
|
||||
}))
|
||||
.setTitle(category.name)
|
||||
@ -324,7 +324,7 @@ module.exports = class TicketManager {
|
||||
.setCustomId(JSON.stringify({
|
||||
action: 'topic',
|
||||
categoryId,
|
||||
referencesMessage,
|
||||
referencesMessageId,
|
||||
referencesTicketId,
|
||||
}))
|
||||
.setTitle(category.name)
|
||||
@ -346,7 +346,7 @@ module.exports = class TicketManager {
|
||||
await this.postQuestions({
|
||||
categoryId,
|
||||
interaction,
|
||||
referencesMessage,
|
||||
referencesMessageId,
|
||||
referencesTicketId,
|
||||
topic,
|
||||
});
|
||||
@ -360,7 +360,7 @@ module.exports = class TicketManager {
|
||||
* @param {string?} [data.topic]
|
||||
*/
|
||||
async postQuestions({
|
||||
action, categoryId, interaction, topic, referencesMessage, referencesTicketId,
|
||||
action, categoryId, interaction, topic, referencesMessageId, referencesTicketId,
|
||||
}) {
|
||||
const [, category] = await Promise.all([
|
||||
interaction.deferReply({ ephemeral: true }),
|
||||
@ -540,14 +540,13 @@ module.exports = class TicketManager {
|
||||
|
||||
/** @type {import("discord.js").Message|undefined} */
|
||||
let message;
|
||||
if (referencesMessage) {
|
||||
referencesMessage = referencesMessage.split('/');
|
||||
if (referencesMessageId) {
|
||||
/** @type {import("discord.js").Message} */
|
||||
message = await (await this.client.channels.fetch(referencesMessage[0]))?.messages.fetch(referencesMessage[1]);
|
||||
message = await interaction.channel.messages.fetch(referencesMessageId);
|
||||
if (message) {
|
||||
// not worth the effort of making system messages work atm
|
||||
if (message.system) {
|
||||
referencesMessage = null;
|
||||
referencesMessageId = null;
|
||||
message = null;
|
||||
} else {
|
||||
if (!message.member) {
|
||||
|
@ -12,7 +12,7 @@ module.exports = {
|
||||
* @param {import("discord.js").ButtonInteraction|import("discord.js").SelectMenuInteraction} interaction
|
||||
*/
|
||||
async useGuild(client, interaction, {
|
||||
referencesMessage,
|
||||
referencesMessageId,
|
||||
referencesTicketId,
|
||||
topic,
|
||||
}) {
|
||||
@ -41,7 +41,7 @@ module.exports = {
|
||||
await client.tickets.create({
|
||||
categoryId: settings.categories[0].id,
|
||||
interaction,
|
||||
referencesMessage,
|
||||
referencesMessageId,
|
||||
referencesTicketId,
|
||||
topic,
|
||||
});
|
||||
@ -53,7 +53,7 @@ module.exports = {
|
||||
new StringSelectMenuBuilder()
|
||||
.setCustomId(JSON.stringify({
|
||||
action: 'create',
|
||||
referencesMessage,
|
||||
referencesMessageId,
|
||||
referencesTicketId,
|
||||
topic,
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user