Skip to content

Commit

Permalink
Improve anti-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
SpreeHertz committed Nov 17, 2021
1 parent d7b0131 commit 3b62b93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelogs | Sandmine.js

### November 17th 2021 (v1.0.6)

1. Improved anti-crashing.

### November 15th 2021 (v1.0.5)

1. Fix table of contents issue.
Expand Down
10 changes: 4 additions & 6 deletions src/events/antiCrash.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const chalk = require('chalk');
const bot = require('../../index');

// no port

if (!process.env.port) {
console.log(chalk.yellowBright('warn') +
chalk.red(` You have not specified your port properly. Your bot will have issues while connecting to your server.`));
Expand All @@ -11,27 +10,26 @@ if (!process.env.port) {
// no host
if (!process.env.host) {
console.log(chalk.yellowBright('warn') +
chalk.red(' You have not specified the host properly. If you\'re using a local server, it\'s recommended that you use localhost.'));
chalk.red(' You have not specified the host properly. If you\'re using a local server, it\'s recommended that you use localhost. Need help? Read the docs: https://sandmine.js.org'));
}

// no username
if (!process.env.bot_username) {
console.log(chalk.yellowBright('warn') +
chalk.red(' You have not specified your bot username. Please specify it and run this project again.'));
chalk.red(' You have not specified your bot username. Please specify it and run this project again. Need help? Read the docs: https://sandmine.js.org'));
}

// if nothing
if (!process.env.bot_username && !process.env.host && !process.env.port) {
console.log(chalk.yellowBright('warn') + chalk.red('You have not specified anything. Please read the docs by going to this URL: https://github.com/spreehertz/sandmine.js'));
console.log(chalk.yellowBright('warn') + chalk.red('You have not specified anything. Please read the docs by going to https://sandmine.js.org.'));
}

// isNaN
if (process.env.port === isNaN) {
console.log(chalk.yellowBright('warn') + chalk.red('It looks like the port you specified is not a number. Make sure you\'ve specified everything correctly.'));
console.log(chalk.yellowBright('warn') + chalk.red('It looks like the port you specified is not a number. Make sure you\'ve specified everything correctly. Need help? Read the docs: https://sandmine.js.org'));
}

// anti crash

module.exports = () => {
process.on('unhandledRejection', (reason, p) => {
console.log(chalk.blueBright('[antiCrash.js]') + chalk.red('Unhandled rejection/crash detected.'));
Expand Down

0 comments on commit 3b62b93

Please sign in to comment.