Removed log beautify for defaut color formating

Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
2023-12-28 13:57:12 +01:00
parent 68fde04bbb
commit ca5bbd0b81
4 changed files with 40 additions and 58 deletions

View File

@@ -1,5 +1,6 @@
import { Command } from "../interfaces"
import config from "./Config"
import color from "./Colors"
import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationGuildCommandsJSONBody, Routes } from "discord.js"
import fs = require("fs")
@@ -51,15 +52,15 @@ async function autoDeployCommands() {
}).join("\n")
if (JSON.stringify(sortedNewCommandsInfo) === JSON.stringify(sortedCurrentCommandsInfo)) {
console.log("Commands are the same, skipping deploy.")
console.log(newCmds)
console.log(color.colorize("Commands are the same, skipping deploy.", "green"))
console.log(color.colorize(currentCmds, "green"))
return
}
(async () => {
try {
console.log("Commands are different, starting deploy.")
console.log(currentCmds)
console.log(color.colorize("Commands are different, starting deploy.", "red"))
console.log(color.colorize(currentCmds, "red"))
console.log(`Started refreshing ${commands.length} application (/) commands.`)
const data = await rest.put(
@@ -67,7 +68,8 @@ async function autoDeployCommands() {
{ body: commands },
) as RESTPutAPIApplicationGuildCommandsJSONBody[]
console.log(newCmds)
console.log(color.colorize("New commands deployed.", "green"))
console.log(color.colorize(newCmds, "green"))
console.log(`Successfully reloaded ${data.length} application (/) commands.`)
} catch (error) {
console.error(error)

33
src/utils/Colors.ts Normal file
View File

@@ -0,0 +1,33 @@
const colors = {
reset: "\x1b[0m",
bright: "\x1b[1m",
dim: "\x1b[2m",
underscore: "\x1b[4m",
blink: "\x1b[5m",
reverse: "\x1b[7m",
hidden: "\x1b[8m",
black: "\x1b[30m",
red: "\x1b[31m",
green: "\x1b[32m",
yellow: "\x1b[33m",
blue: "\x1b[34m",
magenta: "\x1b[35m",
cyan: "\x1b[36m",
white: "\x1b[37m",
bgBlack: "\x1b[40m",
bgRed: "\x1b[41m",
bgGreen: "\x1b[42m",
bgYellow: "\x1b[43m",
bgBlue: "\x1b[44m",
bgMagenta: "\x1b[45m",
bgCyan: "\x1b[46m",
bgWhite: "\x1b[47m",
}
function colorize(text: string, color: keyof typeof colors) {
return colors[color] + text + colors.reset
}
export default { colorize }