Skip to content

Commit 12a32e2

Browse files
committed
🎨 Added custom error for incorrect tokens 🎨
1 parent 226c46b commit 12a32e2

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

main.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,38 @@ client.config = require('./config');
1717
const player = new Player(client, client.config.opt.discordPlayer);
1818
player.extractors.loadDefault();
1919

20+
console.clear()
2021
require('./loader');
2122

22-
client.login(client.config.app.token);
23+
client.login(client.config.app.token)
24+
.catch(async (e) => {
25+
console.clear()
26+
if(e.message == 'An invalid token was provided.'){
27+
try{
28+
const module = await import("chalk");
29+
chalk = module.default || module;
30+
console.error(
31+
chalk.red(`\n
32+
❌ Invalid Token Provided! ❌
33+
change the token in the config file\n\n`)
34+
35+
+ chalk.white(`app: `) + chalk.magenta(`{\n`) +
36+
chalk.green(`token: `) + chalk.yellow(`> > >`) + chalk.red(`'xxx'`) + chalk.yellow(`< < <\n`) +
37+
chalk.green(`playing: `) + chalk.blue(`'by the Community ❤️',\n`) +
38+
chalk.green(`global: `) + chalk.blue(`${client.config.app?.global},\n`) +
39+
chalk.green(`guild: `) + chalk.blue(`'${client.config.app?.guild}',\n`) +
40+
chalk.green(`extraMessages: `) + chalk.blue(`${client.config.app?.extraMessages},\n`) +
41+
chalk.green(`loopMessage: `) + chalk.blue(`${client.config.app?.loopMessage},\n`) +
42+
chalk.green(`lang: `) + chalk.blue(`'${client.config.app?.lang}',\n`) +
43+
chalk.green(`Translate_Timeout: `) + chalk.blue(`${client.config.app?.Translate_Timeout},\n`) +
44+
chalk.green(`enableEmojis: `) + chalk.blue(`${client.config.app?.enableEmojis},\n`) +
45+
chalk.magenta(`},\n`));
46+
47+
process.exit(1);
48+
} catch (e) {
49+
throw new Error('❌ Could not load the Chalk module properly, the error will be printed without highlighting ❌')
50+
}
51+
52+
53+
}
54+
});

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
},
1111
"dependencies": {
1212
"@discord-player/extractor": "^4.3.1",
13-
"@discordjs/opus": "^0.9.0",
1413
"@distube/ytdl-core": "^4.11.8",
14+
"@evan/opus": "^1.0.3",
15+
"@discordjs/opus": "^0.9.0",
16+
"chalk": "^5.3.0",
1517
"discord-player": "6.6.9-dev.1",
1618
"discord.js": "^14.13.0",
1719
"ffmpeg-static": "^5.0.2",

0 commit comments

Comments
 (0)