mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 12:23:09 +02:00
fix: creating the first ticket in a new guild
Previously required `sync`ing (or restarting) to avoid the ticket number error.
This commit is contained in:
parent
2e18fbbef2
commit
eccca3409c
@ -135,7 +135,14 @@ module.exports = class TicketManager {
|
||||
return await this.client.keyv.get(cacheKey);
|
||||
}
|
||||
|
||||
getNextNumber(guildId) {
|
||||
async getNextNumber(guildId) {
|
||||
if (this.$numbers[guildId] === undefined) {
|
||||
const { _max: { number: max } } = await this.client.prisma.ticket.aggregate({
|
||||
_max: { number: true },
|
||||
where: { guildId },
|
||||
});
|
||||
this.client.tickets.$numbers[guildId] = max ?? 0;
|
||||
}
|
||||
this.$numbers[guildId] += 1;
|
||||
return this.$numbers[guildId];
|
||||
}
|
||||
@ -379,7 +386,7 @@ module.exports = class TicketManager {
|
||||
const guild = this.client.guilds.cache.get(category.guild.id);
|
||||
const getMessage = this.client.i18n.getLocale(category.guild.locale);
|
||||
const creator = await guild.members.fetch(interaction.user.id);
|
||||
const number = this.getNextNumber(category.guild.id);
|
||||
const number = await this.getNextNumber(category.guild.id);
|
||||
const channelName = category.channelName
|
||||
.replace(/{+\s?(user)?name\s?}+/gi, creator.user.username)
|
||||
.replace(/{+\s?(nick|display)(name)?\s?}+/gi, creator.displayName)
|
||||
|
Loading…
Reference in New Issue
Block a user