feat: Reminders #44
5 changed files with 39 additions and 4 deletions
|
@ -1,6 +1,10 @@
|
||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM node:16.15.0-alpine3.15
|
FROM node:18.7.0-alpine3.16
|
||||||
|
|
||||||
|
ENV DOCKERIZED=1
|
||||||
|
RUN mkdir /config
|
||||||
|
RUN chown node:node /config
|
||||||
|
|
||||||
RUN apk add dumb-init
|
RUN apk add dumb-init
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
@ -13,5 +17,6 @@ RUN npm ci --only=production
|
||||||
RUN npx tsc
|
RUN npx tsc
|
||||||
|
|
||||||
RUN rm -r src/ tsconfig.json
|
RUN rm -r src/ tsconfig.json
|
||||||
|
RUN npm uninstall typescript discord-api-types @types/sqlite3
|
||||||
|
|
||||||
CMD ["dumb-init", "node", "./dist/index.js"]
|
CMD ["dumb-init", "node", "./dist/index.js"]
|
||||||
|
|
|
@ -28,6 +28,8 @@ services:
|
||||||
container_name: Botanique
|
container_name: Botanique
|
||||||
environment:
|
environment:
|
||||||
- TOKEN_DISCORD=ton-token-va-ici
|
- TOKEN_DISCORD=ton-token-va-ici
|
||||||
|
volumes:
|
||||||
|
- /here/your/path:/config
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -37,6 +39,11 @@ services:
|
||||||
| TOKEN_DISCORD | Token Discord | Aucune |
|
| TOKEN_DISCORD | Token Discord | Aucune |
|
||||||
| DEFAULT_LANG | Langue par défaut | `fr` | Expérimental, si la langue par défaut n'est pas complète (càd 100%), le bot pourrait ne pas fonctionner correctement.<br>Liste des traductions disponibles [ici](./src/locales/).
|
| DEFAULT_LANG | Langue par défaut | `fr` | Expérimental, si la langue par défaut n'est pas complète (càd 100%), le bot pourrait ne pas fonctionner correctement.<br>Liste des traductions disponibles [ici](./src/locales/).
|
||||||
|
|
||||||
|
## Volumes
|
||||||
|
| Chemin | Description
|
||||||
|
| :-------: | :-:
|
||||||
|
| `/config` | Dossier de configuration, par exemple, c'est ici que la base de donnée est.
|
||||||
|
|
||||||
# Contribuer
|
# Contribuer
|
||||||
Toute contribution est la bienvenue !
|
Toute contribution est la bienvenue !
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import loadClient from './utils/client';
|
import loadClient, { quit } from './utils/client';
|
||||||
import loadEvents from './events/loader';
|
import loadEvents from './events/loader';
|
||||||
import loadCommands from './commands/loader';
|
import loadCommands from './commands/loader';
|
||||||
|
|
||||||
|
@ -41,6 +41,12 @@ const run = async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`Botanique "${client.user?.username}" v${client.config.version} started!`);
|
console.log(`Botanique "${client.user?.username}" v${client.config.version} started!`);
|
||||||
|
|
||||||
|
// ^C
|
||||||
|
process.on('SIGINT', () => quit(client));
|
||||||
|
|
||||||
|
// Container force closed
|
||||||
|
process.on('SIGTERM', () => quit(client));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
throw logStart(client_name, false);
|
throw logStart(client_name, false);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Collection } from 'discord.js';
|
import { Collection } from 'discord.js';
|
||||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||||
|
import { Database } from 'sqlite3';
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|
||||||
|
@ -34,8 +35,9 @@ declare module 'discord.js' {
|
||||||
interaction: (interaction: CommandInteraction, client: Client) => unknown
|
interaction: (interaction: CommandInteraction, client: Client) => unknown
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
}
|
},
|
||||||
/** Store all the localizations */
|
/** Store all the localizations */
|
||||||
locales: Map<string, Map<string, string>>
|
locales: Map<string, Map<string, string>>,
|
||||||
|
db: Database,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Client, Collection, GatewayIntentBits } from 'discord.js';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { loadLocales } from './locales';
|
import { loadLocales } from './locales';
|
||||||
import '../modules/client';
|
import '../modules/client';
|
||||||
|
import { Database } from 'sqlite3';
|
||||||
|
|
||||||
/** Creation of the client and definition of its properties. */
|
/** Creation of the client and definition of its properties. */
|
||||||
export default async () => {
|
export default async () => {
|
||||||
|
@ -26,5 +27,19 @@ export default async () => {
|
||||||
console.log('Translations progression :');
|
console.log('Translations progression :');
|
||||||
client.locales = await loadLocales(client.config.default_lang);
|
client.locales = await loadLocales(client.config.default_lang);
|
||||||
|
|
||||||
|
client.db = new Database(`${
|
||||||
|
process.env.DOCKERIZED === '1' ? '/config' : './config'
|
||||||
|
}/db.sqlite3`);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const quit = (client: Client) => {
|
||||||
|
// Close DB
|
||||||
|
client.db.close();
|
||||||
|
|
||||||
|
// Close client
|
||||||
|
client.destroy();
|
||||||
|
|
||||||
|
console.log('ciao!');
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue