Files
SupportBot/Structures/TicketID.js
T

30 lines
608 B
JavaScript
Raw Normal View History

2021-10-04 20:41:05 +01:00
// SupportBot | Emerald Services
// Ticket ID Structure
2025-09-20 23:09:22 +01:00
const db = require("./Database")
2021-10-04 20:41:05 +01:00
class TicketNumberID {
2021-11-23 15:48:45 -06:00
static async pad() {
2025-09-20 23:09:22 +01:00
let num = await this.get()
let n = num + ""
await this.set(num + 1)
return n.length >= 4 ? n : new Array(4 - n.length + 1).join("0") + n
2021-10-24 22:41:46 +01:00
}
2021-12-18 22:14:11 -06:00
static async get() {
2025-09-20 23:09:22 +01:00
const row = db.getTicketPanel()
if (!row) return await this.set(0)
return row.id
2021-10-24 22:41:46 +01:00
}
2021-12-18 22:14:11 -06:00
static async set(value) {
2025-09-20 23:09:22 +01:00
db.saveTicketPanel(`panel-${value}`, "none")
return value
2021-10-24 22:41:46 +01:00
}
2021-12-18 22:14:11 -06:00
static async reset() {
2025-09-20 23:09:22 +01:00
return await this.set(0)
2021-10-24 22:41:46 +01:00
}
2021-10-04 20:41:05 +01:00
}
2025-09-20 23:09:22 +01:00
module.exports = TicketNumberID