Updated to new color script

This commit is contained in:
2024-01-12 20:52:05 +01:00
parent a6254a2493
commit 45762c19d6
7 changed files with 39 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ import {
color,
devMessage,
} from "../../../config/options.json"
import colorLog from "../../utils/functions/colors"
import { getGuild, getIGN } from "../../utils/Hypixel"
import { Cron, GuildData } from "../../interfaces"
import Illegitimate from "../../utils/Illegitimate"
@@ -16,7 +17,7 @@ async function guildWeekly() {
) as TextChannel
if (!channel) {
console.log("Guild log channel not found")
console.log(colorLog("Guild log channel not found", "red"))
return
}

View File

@@ -1,4 +1,5 @@
import { ChatInputCommandInteraction, ButtonInteraction } from "discord.js"
import color from "../../../utils/functions/colors"
import { Event } from "../../../interfaces"
export = {
@@ -10,29 +11,32 @@ export = {
execute(interaction: ChatInputCommandInteraction | ButtonInteraction) {
if (interaction.isCommand()) {
try {
console.log(
console.log(color(
interaction.user.username +
" ran " +
interaction.commandName +
" " +
interaction.options.getSubcommand(),
"pink")
)
} catch {
console.log(
console.log(color(
interaction.user.username +
" ran " +
interaction.commandName,
"pink")
)
}
}
if (interaction.isButton()) {
console.log(
console.log(color(
interaction.user.username +
"#" +
interaction.user.discriminator +
" clicked " +
interaction.customId,
"pink")
)
return
}

View File

@@ -1,5 +1,6 @@
import { Event } from "../../../interfaces"
import { ExtendedClient as Client } from "../../../utils/Client"
import color from "../../../utils/functions/colors"
export = {
name: "conolelog",
@@ -8,6 +9,6 @@ export = {
event: "ready",
execute(client: Client) {
console.log("Logged in as " + client.user!.tag + "!")
console.log(color("Logged in as " + client.user!.tag + "!", "green"))
},
} as Event

View File

@@ -1,7 +1,6 @@
import { Command } from "../interfaces"
import chalk from "chalk"
import color from "./functions/colors"
import env from "./Env"
// import color from "./functions/colors"
import {
REST,
RESTGetAPIApplicationGuildCommandResult,
@@ -11,9 +10,6 @@ import {
import fs = require("fs")
type FileType = "js" | "ts"
const oldColor = chalk.hex("#f38ba8")
const newColor = chalk.hex("#b4befe")
export default async function autoDeployCommands(fileType: FileType) {
const commands = []
let commandFiles: string[] = []
@@ -90,21 +86,17 @@ export default async function autoDeployCommands(fileType: FileType) {
JSON.stringify(sortedCurrentCommandsInfo)
) {
console.log(
// color.colorize("Commands are the same, skipping deploy.", "green"),
newColor("Commands are the same, skipping deploy."),
color("Commands are the same, skipping deploy.", "lavender"),
)
// console.log(color.colorize(newCmds, "green"))
console.log(newColor(newCmds))
console.log(color(newCmds, "lavender"))
return
}
try {
console.log(
// color.colorize("Commands are different, starting deploy.", "red"),
oldColor("Commands are different, starting deploy."),
color("Commands are different, starting deploy.", "red"),
)
// console.log(color.colorize(currentCmds, "red"))
console.log(oldColor(currentCmds))
console.log(color(currentCmds, "red"))
console.log(
`Started refreshing ${commands.length} application (/) commands.`,
)
@@ -114,10 +106,8 @@ export default async function autoDeployCommands(fileType: FileType) {
{ body: commands },
)) as RESTPutAPIApplicationGuildCommandsJSONBody[]
// console.log(color.colorize("New commands deployed.", "green"))
// console.log(color.colorize(newCmds, "green"))
console.log(newColor("New commands deployed."))
console.log(newColor(newCmds))
console.log(color("New commands deployed.", "lavender"))
console.log(color(newCmds, "lavender"))
console.log(
`Successfully reloaded ${data.length} application (/) commands.`,
)

View File

@@ -1,4 +1,5 @@
import { Client, Collection, GatewayIntentBits, Partials } from "discord.js"
import color from "./functions/colors"
import { Command } from "../interfaces"
import { ContextMenu } from "../interfaces"
import { Button } from "../interfaces"
@@ -37,17 +38,17 @@ export class ExtendedClient extends Client {
async start() {
let token: string
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) {
console.log("Running in development mode. [ts-node]")
console.log(color("Running in development mode. [ts-node]", "lavender"))
loadAllEvents(this, "ts")
token = env.dev.devtoken!
autoDeployCommands("ts")
} else if (process.env.NODE_ENV === "dev" && !process.env.TYPESCRIPT) {
console.log("Running in development mode.")
console.log(color("Running in development mode.", "lavender"))
loadAllEvents(this, "js")
token = env.dev.devtoken!
autoDeployCommands("js")
} else {
console.log("Running in production mode.")
console.log(color("Running in production mode.", "green"))
loadAllEvents(this, "js")
token = env.prod.token!
}

View File

@@ -1,4 +1,5 @@
import { ExtendedClient as Client } from "./Client"
import color from "./functions/colors"
import { Redis } from "ioredis"
import env from "./Env"
import { connect } from "mongoose"
@@ -13,10 +14,10 @@ class Bot {
client.start()
loadCronEvents()
redis.on("ready", () => {
console.log("Connected to Redis")
console.log(color("Connected to Redis", "green"))
})
connect(env.prod.mongoURI!, {}).then(() => {
console.log("Connected to MongoDB")
console.log(color("Connected to MongoDB", "green"))
})
}
}

View File

@@ -1,4 +1,17 @@
import chalk from "chalk"
const colors = {
red: "#f38ba8",
lavender: "#b4befe",
green: "#a6e3a1",
pink: "#f5c2e7"
}
export default function color(text: string, type: keyof typeof colors) {
return chalk.hex(colors[type])(text)
}
/* const colors = {
reset: "\x1b[0m",
bright: "\x1b[1m",
dim: "\x1b[2m",
@@ -28,4 +41,4 @@ const colors = {
export default function colorize(text: string, color: keyof typeof colors) {
return colors[color] + text + colors.reset
}
} */