Changed TicketData Structure
This commit is contained in:
1 parent
e740c17837
commit
b6a0016f5f
4 files changed
+38
-27
No files matched your search
+19
-1
@@ -51,7 +51,11 @@ module.exports = new Command({
|
||||
}
|
||||
|
||||
// Ticket ID
|
||||
let ticketNumberID = TicketNumberID.pad(interaction.guild.id);
|
||||
let ticketNumberID = await TicketNumberID.pad();
|
||||
|
||||
let TicketData = await JSON.parse(
|
||||
fs.readFileSync("./Data/TicketData.json", "utf8")
|
||||
);
|
||||
|
||||
// Ticket Subject
|
||||
const TicketSubject =
|
||||
@@ -105,6 +109,20 @@ module.exports = new Command({
|
||||
type: "GUILD_TEXT",
|
||||
}
|
||||
);
|
||||
await TicketData.tickets.push({
|
||||
id: ticketChannel.id,
|
||||
name: ticketChannel.name,
|
||||
user: Author.id,
|
||||
number: ticketNumberID,
|
||||
reason: TicketSubject,
|
||||
});
|
||||
fs.writeFileSync(
|
||||
"./Data/TicketData.json",
|
||||
JSON.stringify(TicketData, null, 4),
|
||||
(err) => {
|
||||
if (err) console.error(err);
|
||||
}
|
||||
);
|
||||
|
||||
if (
|
||||
interaction.channel.name === supportbot.ReactionChannel ||
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
{}
|
||||
{
|
||||
"id": 10,
|
||||
"tickets": []
|
||||
}
|
||||
@@ -1,3 +1 @@
|
||||
{
|
||||
"TicketPanelID": ""
|
||||
}
|
||||
{"TicketPanelID":""}
|
||||
+14
-22
@@ -14,74 +14,66 @@ const supportbot = yaml.load(
|
||||
);
|
||||
|
||||
class TicketNumberID {
|
||||
static pad(guildId) {
|
||||
let n = this.get(guildId) + "";
|
||||
static async pad() {
|
||||
let n = this.get() + "";
|
||||
let z = "0";
|
||||
let width = 4;
|
||||
setTimeout(() => {
|
||||
this.set(guildId, this.get(guildId) + 1);
|
||||
}, 50);
|
||||
await this.set(this.get() + 1);
|
||||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
||||
}
|
||||
|
||||
static get(guildId) {
|
||||
static get() {
|
||||
let ticketnumberID = JSON.parse(
|
||||
fs.readFileSync("./Data/TicketData.json", "utf8")
|
||||
);
|
||||
|
||||
if (!ticketnumberID[guildId]) {
|
||||
ticketnumberID[guildId] = {
|
||||
id: 0,
|
||||
};
|
||||
if (!ticketnumberID.id) {
|
||||
ticketnumberID.id = 0;
|
||||
|
||||
fs.writeFileSync(
|
||||
"./Data/TicketData.json",
|
||||
JSON.stringify(ticketnumberID, null, 4),
|
||||
(err) => {
|
||||
if (err) console.log(err);
|
||||
if (err) console.error(err);
|
||||
}
|
||||
);
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
return ticketnumberID[guildId].id;
|
||||
return ticketnumberID.id;
|
||||
}
|
||||
}
|
||||
|
||||
static set(guildId, value) {
|
||||
static set(value) {
|
||||
let ticketnumberID = JSON.parse(
|
||||
fs.readFileSync("./Data/TicketData.json", "utf8")
|
||||
);
|
||||
|
||||
ticketnumberID[guildId] = {
|
||||
id: value,
|
||||
};
|
||||
ticketnumberID.id = value;
|
||||
|
||||
fs.writeFileSync(
|
||||
"./Data/TicketData.json",
|
||||
JSON.stringify(ticketnumberID, null, 4),
|
||||
(err) => {
|
||||
if (err) console.log(err);
|
||||
if (err) console.error(err);
|
||||
}
|
||||
);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static reset(guildId) {
|
||||
static reset() {
|
||||
let ticketnumberID = JSON.parse(
|
||||
fs.readFileSync("./Data/TicketData.json", "utf8")
|
||||
);
|
||||
|
||||
ticketnumberID[guildId] = {
|
||||
id: 0,
|
||||
};
|
||||
ticketnumberID.id = 0;
|
||||
|
||||
fs.writeFileSync(
|
||||
"./Data/TicketData.json",
|
||||
JSON.stringify(ticketnumberID, null, 4),
|
||||
(err) => {
|
||||
if (err) console.log(err);
|
||||
if (err) console.error(err);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user