updated cleardatabase with chalk
This commit is contained in:
@@ -67,7 +67,7 @@ module.exports = () => {
|
||||
.setDisabled(false)
|
||||
.setStyle("DANGER")
|
||||
.setLabel("Delete Ticket")
|
||||
.setEmoji("❌")
|
||||
.setEmoji("✖️")
|
||||
)
|
||||
var closeRowClosed = new discord.MessageActionRow()
|
||||
.addComponents(
|
||||
@@ -76,7 +76,7 @@ module.exports = () => {
|
||||
.setDisabled(false)
|
||||
.setStyle("DANGER")
|
||||
.setLabel("Delete Ticket")
|
||||
.setEmoji("❌")
|
||||
.setEmoji("✖️")
|
||||
)
|
||||
.addComponents(
|
||||
new discord.MessageButton()
|
||||
|
||||
@@ -1,28 +1,53 @@
|
||||
const fs = require('fs')
|
||||
|
||||
const dataPaths = ["./storage/tickets","./storage/transcripts","./storage/userTickets"]
|
||||
|
||||
var index = 0
|
||||
|
||||
dataPaths.forEach((path) => {
|
||||
try {
|
||||
fs.rmdirSync(path,{recursive:true,force:true})
|
||||
}catch{
|
||||
console.log(path,"doesn't exist")
|
||||
}
|
||||
setTimeout(() => {
|
||||
try{
|
||||
fs.mkdirSync(path)
|
||||
}catch{
|
||||
console.log(path,"already exists")
|
||||
}
|
||||
index++
|
||||
},500)
|
||||
const readline = require("readline")
|
||||
const rl = readline.createInterface({
|
||||
input:process.stdin,
|
||||
output:process.stdout,
|
||||
terminal:true
|
||||
})
|
||||
|
||||
setInterval(() => {
|
||||
if (index >= 3){
|
||||
console.log("All local data is cleared!")
|
||||
process.exit(1)
|
||||
}
|
||||
},500)
|
||||
const ask = async () => {
|
||||
const chalk = await (await import("chalk")).default
|
||||
rl.question(chalk.yellow("WARNING: are you sure that there are",chalk.red("no tickets open"),"at the moment? ")+chalk.green("(yes/no)")+"\n",(answer) => {
|
||||
if (answer != "1" && !answer.toLowerCase().startsWith("yes")){
|
||||
console.log(chalk.red("invalid answer"))
|
||||
ask()
|
||||
return
|
||||
}
|
||||
console.log(chalk.green("clearing data..."))
|
||||
runClear()
|
||||
rl.close()
|
||||
})
|
||||
}
|
||||
ask()
|
||||
|
||||
const runClear = async () => {
|
||||
const chalk = await (await import("chalk")).default
|
||||
console.log(chalk.blue("You can get a node.js warning below, just ignore that, it's not important!"))
|
||||
const dataPaths = ["./storage/tickets","./storage/transcripts","./storage/userTickets"]
|
||||
|
||||
var index = 0
|
||||
|
||||
dataPaths.forEach((path) => {
|
||||
try {
|
||||
fs.rmdirSync(path,{recursive:true,force:true})
|
||||
}catch{
|
||||
console.log(path,"doesn't exist")
|
||||
}
|
||||
setTimeout(() => {
|
||||
try{
|
||||
fs.mkdirSync(path)
|
||||
}catch{
|
||||
console.log(path,"already exists")
|
||||
}
|
||||
index++
|
||||
},500)
|
||||
})
|
||||
|
||||
setInterval(() => {
|
||||
if (index >= 3){
|
||||
console.log(chalk.bgGreen("All local data is cleared!"))
|
||||
process.exit(1)
|
||||
}
|
||||
},500)
|
||||
}
|
||||
@@ -14,6 +14,7 @@ const transcriptStorage = bot.transcriptStorage
|
||||
* @param {"delete"|"close"|"deletenotranscript"} mode
|
||||
*/
|
||||
exports.closeTicket = async (interaction,prefix,mode) => {
|
||||
const chalk = await (await import("chalk")).default
|
||||
const channelmessages = await interaction.channel.messages.fetch()
|
||||
|
||||
channelmessages.sweep((msgSweep) => {
|
||||
@@ -29,6 +30,10 @@ exports.closeTicket = async (interaction,prefix,mode) => {
|
||||
var getuserID = userTicketStorage.getItem(interaction.channel.id)
|
||||
var getusernameStep1 = client.users.cache.find(u => u.id === getuserID)
|
||||
|
||||
if (!getusernameStep1){
|
||||
console.log(chalk.red("[database error]"),"something went wrong when getting the data in the database.\nNo panic, this error fixes itself!")
|
||||
}
|
||||
|
||||
var enableTranscript = true
|
||||
|
||||
if (mode == "delete"){
|
||||
@@ -61,7 +66,7 @@ exports.closeTicket = async (interaction,prefix,mode) => {
|
||||
.setDisabled(false)
|
||||
.setStyle("DANGER")
|
||||
.setLabel("Delete Ticket")
|
||||
.setEmoji("❌")
|
||||
.setEmoji("✖️")
|
||||
)
|
||||
.addComponents(
|
||||
new discord.MessageButton()
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = () => {
|
||||
.setDisabled(false)
|
||||
.setStyle("DANGER")
|
||||
.setLabel("Delete Ticket")
|
||||
.setEmoji("❌")
|
||||
.setEmoji("✖️")
|
||||
)
|
||||
|
||||
//ticket button click / create ticket
|
||||
|
||||
@@ -68,9 +68,9 @@ if (process.argv[2] != "slash"){
|
||||
|
||||
}
|
||||
|
||||
process.on('unhandledRejection',async (error) => {
|
||||
const chalk = await (await import("chalk")).default
|
||||
console.log(chalk.red("ERROR: ")+error)
|
||||
})
|
||||
//process.on('unhandledRejection',async (error) => {
|
||||
// const chalk = await (await import("chalk")).default
|
||||
// console.log(chalk.red("ERROR: ")+error)
|
||||
//})
|
||||
|
||||
client.login(config.auth_token)
|
||||
+3
-3
@@ -6,9 +6,9 @@
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"slashEnable":"node index.js slash enable",
|
||||
"slashDisable":"node index.js slash disable",
|
||||
"cleardata":"node ./core/dynamicdatabase/cleardata.js"
|
||||
"slashEnable": "node index.js slash enable",
|
||||
"slashDisable": "node index.js slash disable",
|
||||
"cleardata": "node ./core/dynamicdatabase/cleardata.js"
|
||||
},
|
||||
"author": "DJdj Development",
|
||||
"license": "ISC",
|
||||
|
||||
Reference in New Issue
Block a user