Compare commits

...

4 commits

Author SHA1 Message Date
76d19dec6e
re-add include 2024-11-02 18:04:22 +01:00
a550a8bc3f
add sql directory to dist 2024-11-02 18:04:14 +01:00
c98fa2dd56
update async-queue 2024-11-02 18:03:48 +01:00
e9ff15085c
don't compile tests 2024-11-02 18:01:51 +01:00
10 changed files with 23 additions and 18 deletions

View file

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

6
package-lock.json generated
View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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