feat: Add start:no-db command
This commit is contained in:
parent
b12b3c2e2e
commit
8a79f2671b
5 changed files with 22 additions and 18 deletions
|
|
@ -8,6 +8,7 @@
|
|||
"build:tsc": "tsc",
|
||||
"build": "npm run build:prisma && npm run build:tsc",
|
||||
"start": "prisma migrate deploy && node .",
|
||||
"start:no-db": "npm run build:tsc && node .",
|
||||
"dev": "npm run build && npm run start"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -30,16 +30,26 @@ export class DiscordBot {
|
|||
}
|
||||
|
||||
const commandsCachePath = join(cwd(), "cache", "commands");
|
||||
await mkdir(commandsCachePath);
|
||||
const commandsCache: { [key: string]: string } = JSON.parse(await readFile(join(commandsCachePath, "list.json"), "utf-8") || "{}");
|
||||
await mkdir(commandsCachePath, {
|
||||
recursive: true
|
||||
});
|
||||
let commandsCache: { [key: string]: string }
|
||||
try {
|
||||
commandsCache = JSON.parse(
|
||||
await readFile(join(commandsCachePath, "list.json"), "utf-8")
|
||||
);
|
||||
} catch {
|
||||
commandsCache = {};
|
||||
}
|
||||
|
||||
for (const [command, id] of Object.entries(commandsCache)) {
|
||||
if (commandExecuteNameHashMap[command]) {
|
||||
continue;
|
||||
}
|
||||
console.log(`sync(delete) command: ${command}(${id})`);
|
||||
await this.deleteCommand(id);
|
||||
}
|
||||
|
||||
|
||||
await this.rest.put(
|
||||
Routes.applicationCommands(APPLICATION_ID),
|
||||
{
|
||||
|
|
@ -58,7 +68,9 @@ export class DiscordBot {
|
|||
).reduce<Record<string, string>>((acc, cur) => {
|
||||
acc[cur.name] = cur.id;
|
||||
return acc;
|
||||
}, {})
|
||||
}, {}),
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
} catch(err) {
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
import { bot } from "..";
|
||||
|
||||
export default function remove() {
|
||||
bot.deleteCommand("1463496119135899671");
|
||||
bot.deleteCommand("1463496119135899675");
|
||||
bot.deleteCommand("1463496119135899676");
|
||||
bot.deleteCommand("1463496119135899677");
|
||||
bot.deleteCommand("1463496119286759606");
|
||||
bot.deleteCommand("1464993345427476648");
|
||||
bot.deleteCommand("1464993345427476649");
|
||||
}
|
||||
|
|
@ -4,15 +4,15 @@ import { APPLICATION_ID, DISCORD_TOKEN } from "./env";
|
|||
|
||||
export const bot = new DiscordBot(DISCORD_TOKEN);
|
||||
|
||||
bot.client.once("ready", async (client) => {
|
||||
bot.client.once("clientReady", async (client) => {
|
||||
await bot.registerCommands();
|
||||
await bot.registerEvents();
|
||||
|
||||
console.log(
|
||||
"registerCommands: \n" +
|
||||
"registerCommands: \n| " +
|
||||
(
|
||||
(await client.rest.get(Routes.applicationCommands(APPLICATION_ID))) as any[]
|
||||
).map(info => `name: ${info.name} id: ${info.id}`).join("\n")
|
||||
).map(info => `name: ${info.name} id: ${info.id}`).join("\n| ")
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ export namespace OutputHandler {
|
|||
}
|
||||
export async function errorLog(...args: any[]): Promise<void> {
|
||||
const output = getErrorOutput(...args);
|
||||
console.log(output);
|
||||
|
||||
await mkdir(dirname(ErrorLogPath), { recursive: true });
|
||||
|
||||
const fileHandle = await open(ErrorLogPath, "a");
|
||||
|
|
|
|||
Loading…
Reference in a new issue