Skip to content

Commit

Permalink
Removed Spinners (Sparked Host Incompatibility)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrigamingWasTaken committed Nov 26, 2023
1 parent b427476 commit fac299b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 181 deletions.
147 changes: 11 additions & 136 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"dotenv": "^16.3.1",
"emoji-regex": "^10.3.0",
"js-yaml": "^4.1.0",
"mongodb": "^6.3.0",
"ora": "^3.2.0"
"mongodb": "^6.3.0"
}
}
12 changes: 1 addition & 11 deletions src/core/deploy-commands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import path from 'path';
import { SlashCommandBuilder, REST, Routes, Collection, Snowflake } from 'discord.js';
import { ansi, logging, spinner } from './utilities';
import { ansi, logging } from './utilities';
const loggingConfig = loadYaml("bot/logging.yml")

interface Command {
Expand Down Expand Up @@ -65,15 +65,12 @@ export async function getCommands() {

export async function deployCommands() {
const rest = new REST().setToken(process.env.token);
let spin = spinner("Clearing global commands cache...", "blue")
try {
await rest.put(Routes.applicationCommands(process.env.clientId), {
body: []
})
spin.stop()
logging("Cleared global commands cache!", "success")
} catch (error) {
spin.stop()
logging("An error occured when trying to clear the global commands cache\n" + error, "error")
}

Expand Down Expand Up @@ -105,32 +102,25 @@ export async function deployCommands() {
}
}
// Reload guild commands
spin = spinner(`(/) Reloading commands for ${guildCommands.size} guilds...`,"yellow")
guildCommands.forEach(async (guildCmd, guildId: string) => {
try {
console.log(guildCmd)
const data = await rest.put(Routes.applicationGuildCommands(process.env.clientId, "" + guildId), {
body: guildCmd
})
} catch (error) {
spin.clear()
logging(`(/) Exception occured while refreshing commands for "${guildId}":\n${error}`, "error")
spin.render()
}
})
spin.stop()
logging(`(/) Reloaded guild-specific commands for ${guildCommands.size} guilds.`,"success")

// Reload global commands
spin = spinner(`(/) Reloading ${globalCommands.length} global commands`, "yellow")
try {
const data = await rest.put(Routes.applicationCommands(process.env.clientId), {
body: globalCommands
})
spin.stop()
logging(`(/) Reloaded ${globalCommands.length} global commands`, "success")
} catch (error) {
spin.stop()
logging(`(/) Exception occured while reloading the global commands:\n${error}`, "error")
}
}
29 changes: 0 additions & 29 deletions src/core/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import ora from "ora"
import { Color, Ora } from "ora"
import { Console } from "console"
import path from "path"
import fs from "fs"
Expand Down Expand Up @@ -62,33 +60,6 @@ export const ansi = (inputString) =>
colors[colorName.toLowerCase()] ? colors[colorName.toLowerCase()] : match
);

export function spinner(text: string, color: Color): Ora {
const spin = ora({ text: text })
spin.color = color
spin.spinner = {
interval: 80,
frames: [
"[ ]",
"[= ]",
"[== ]",
"[=== ]",
"[====]",
"[ ===]",
"[ ==]",
"[ =]",
"[ ]",
"[ =]",
"[ ==]",
"[ ===]",
"[====]",
"[=== ]",
"[== ]",
"[= ]"
]
}
return spin
}

type LoggingType =
| "info"
| "success"
Expand Down
Loading

0 comments on commit fac299b

Please sign in to comment.