Compare commits
2 commits
3d0fe87717
...
7eb61b0700
Author | SHA1 | Date | |
---|---|---|---|
7eb61b0700 | |||
574583389f |
4 changed files with 29 additions and 8 deletions
|
@ -5,7 +5,8 @@
|
||||||
"es6": true
|
"es6": true
|
||||||
},
|
},
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2021
|
"ecmaVersion": 2021,
|
||||||
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
"description": "Bot discord",
|
"description": "Bot discord",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"main": "node ."
|
"main": "node .",
|
||||||
|
"eslint": "eslint src"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -18,5 +19,6 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dotenv": "^16.0.1",
|
"dotenv": "^16.0.1",
|
||||||
"eslint": "^8.13.0"
|
"eslint": "^8.13.0"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { Client, Intents } = require('discord.js');
|
import loadClient from './utils/client.js';
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
console.log('Starting Botanique...');
|
console.log('Starting Botanique...');
|
||||||
|
@ -10,12 +10,11 @@ const run = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client Discord.JS
|
// Client Discord.JS
|
||||||
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
const client = await loadClient().catch(() => {
|
||||||
client.config = { token_discord: process.env.TOKEN_DISCORD };
|
throw 'Client ❌';
|
||||||
|
});
|
||||||
if (client) {
|
if (client) {
|
||||||
console.log('Client ✅');
|
console.log('Client ✅');
|
||||||
} else {
|
|
||||||
throw 'Client ❌';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await client.login(client.config.token_discord);
|
await client.login(client.config.token_discord);
|
||||||
|
|
19
src/utils/client.js
Normal file
19
src/utils/client.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { Client, Intents } from 'discord.js';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
const { version } = JSON.parse(readFileSync('./package.json'));
|
||||||
|
|
||||||
|
// Création du client et de ses propriétés
|
||||||
|
export default async () => {
|
||||||
|
const client = new Client({
|
||||||
|
intents: [
|
||||||
|
Intents.FLAGS.GUILDS,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
client.config = {
|
||||||
|
version: version,
|
||||||
|
token_discord: process.env.TOKEN_DISCORD,
|
||||||
|
};
|
||||||
|
|
||||||
|
return client;
|
||||||
|
};
|
Loading…
Reference in a new issue