Compare commits

..

No commits in common. "76d19dec6e1bd1d2b2e8284b2382796f9d4e849a" and "10f5bf65b3b91e53a300262ffa65b4cfc7b21fc9" have entirely different histories.

10 changed files with 18 additions and 23 deletions

View file

@ -5,3 +5,5 @@
!package-lock.json
!LICENSE
!tsconfig.json
src/tests/

6
package-lock.json generated
View file

@ -1454,9 +1454,9 @@
}
},
"node_modules/@sapphire/async-queue": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.4.tgz",
"integrity": "sha512-id65RxAx34DCk8KAVTPWwcephJSkStiS9M15F87+zvK2gK47wf7yeRIo8WiuKeXQS6bsyo/uQ/t0QW1cLmSb+A==",
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.3.tgz",
"integrity": "sha512-x7zadcfJGxFka1Q3f8gCts1F0xMwCKbZweM85xECGI0hBTeIZJGGCrHgLggihBoprlQ/hBmDR5LKfIPqnmHM3w==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",

View file

@ -4,13 +4,13 @@
"description": "Bot discord",
"main": "src/index.js",
"scripts": {
"compile": "rm -r dist 2> /dev/null; npx tsc; cp -r ./src/sql ./dist/sql",
"compile": "rm -r dist 2> /dev/null; npx tsc",
"main": "npm run compile && node ./dist/index.js",
"debug": "npx tsnd --respawn ./src/index.ts",
"lint": "npx eslint src",
"format-check": "npx prettier --check src",
"format-write": "npx prettier --write src",
"test": "npx jest"
"test": "npm run compile && npx jest"
},
"repository": {
"type": "git",

View file

@ -1,10 +1,10 @@
import { PlayerEvents, useMainPlayer } from "discord-player";
import { Client } from "discord.js";
import { readdir } from "fs/promises";
import { isDev, splitFilenameExtensions } from "../utils/misc";
import { splitFilenameExtensions } from "../utils/misc";
/** Load all the events */
export default async (client: Client) => {
export default async (client: Client, isDev: boolean) => {
const events_categories = (await readdir(__dirname, { withFileTypes: true }))
.filter((element) => element.isDirectory())
.map((element) => element.name);

View file

@ -1,8 +1,8 @@
import { isDev } from "./utils/misc";
const isDev = process.env.NODE_ENV !== "production";
/** Load the app */
const start_app = () => {
import("./load").then((l) => l.run().catch((error) => console.error(error)));
import("./load").then((l) => l.run(isDev).catch((error) => console.error(error)));
};
// Load .env if not in prod

View file

@ -4,15 +4,15 @@ import loadEvents from "./events/loader";
import loadModals from "./modals/loader";
import loadClient, { quit } from "./utils/client";
import { isDev, logStart } from "./utils/misc";
import { logStart } from "./utils/misc";
/** Run the bot */
export const run = async () => {
export const run = async (isDev: boolean) => {
console.log("Starting Botanique...");
// Client Discord.JS
const client_name = "Client";
await loadClient()
await loadClient(isDev)
.then(async (client) => {
if (isDev) {
// Attach debugging listeners
@ -21,7 +21,7 @@ export const run = async () => {
// Events Discord.JS and Player
const events_name = "Events";
await loadEvents(client)
await loadEvents(client, isDev)
.then(() => console.log(logStart(events_name, true)))
.catch((err) => {
console.error(err);

View file

@ -6,10 +6,9 @@ import "../modules/client";
import { loadLocales } from "./locales";
import { YoutubeiExtractor } from "discord-player-youtubei";
import { readSQL } from "./db";
import { isDev } from "./misc";
/** Creation of the client and definition of its properties */
export default async () => {
export default async (isDev: boolean) => {
const activities = isDev ? [] : [{ name: "/help", type: ActivityType.Watching }];
const client: Client = new Client({

View file

@ -1,9 +1,7 @@
import fs from "node:fs";
import { isDev } from "./misc";
export const readSQL = (path: string) => {
const root = isDev ? "./src" : "./dist";
const dir = root + "/sql/";
const dir = "./src/sql/";
if (!path.startsWith(dir)) {
path = dir + path;
}

View file

@ -1,8 +1,5 @@
import { GuildMember } from "discord.js";
/** Check if we are in the dev environnement */
export const isDev = process.env.NODE_ENV !== "production";
/**
* Log module status
* @param {string} name Module name

View file

@ -102,6 +102,5 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["./**/*.ts", "./src/locales/*.json"],
"exclude": ["./src/tests"]
"include": ["./**/*.ts", "./src/locales/*.json"]
}