Skip to content

Commit

Permalink
Merge pull request #172 from Skript-MC/v2
Browse files Browse the repository at this point in the history
🔖 2.1.5
  • Loading branch information
Romitou authored Sep 1, 2021
2 parents fb66b68 + 163908c commit 4baff83
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 50 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swan",
"version": "2.1.4",
"version": "2.1.5",
"description": "Bot discord de Skript-MC.",
"main": "./src/main.ts",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/commands/fun/idea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class IdeaCommand extends Command {

const randomIdea = ideas.random(1)[0];

if (!randomIdea) {
await message.channel.send(config.messages.noIdeaFound);
return;
}

const embed = new MessageEmbed()
.setColor(settings.colors.default)
.setAuthor(
Expand Down
8 changes: 2 additions & 6 deletions src/listeners/client/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ class ClientErrorListener extends Listener {
}

public exec(error: Error): void {
captureException(error);
Logger.error('Oops, something went wrong with the Swan Client!');
if (process.env.NODE_ENV === 'production') {
captureException(error);
throw new Error(error.stack);
} else {
Logger.error(error.stack);
}
Logger.error(error.stack);
}
}

Expand Down
9 changes: 2 additions & 7 deletions src/listeners/commandHandler/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ class CommandHandlerErrorListener extends Listener {
}

public async exec(error: Error, message: Message, command: Command): Promise<void> {
captureException(error);
await message.channel.send(messages.global.oops).catch(noop);
Logger.error('Oops, something went wrong with a command!');
Logger.detail(`Command: ${command}`);
Logger.detail(`Message: ${message.url}`);

if (process.env.NODE_ENV === 'production') {
captureException(error);
throw new Error(error.stack);
} else {
Logger.error(error.stack);
}
Logger.error(error.stack);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/listeners/inhibitorHandler/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ class InhibitorHandlerErrorListener extends Listener {
}

public exec(error: Error, inhibitor: Inhibitor): void {
captureException(error);
Logger.error('Oops, something went wrong with an inhibitor!');
Logger.detail(`Inhibitor: ${inhibitor.id}`);
if (process.env.NODE_ENV === 'production') {
captureException(error);
throw new Error(error.stack);
} else {
Logger.error(error.stack);
}
Logger.error(error.stack);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/listeners/listenerHandler/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ class ListenerHandlerErrorListener extends Listener {
}

public exec(error: Error, listener: Listener): void {
captureException(error);
Logger.error('Oops, something went wrong with a listener!');
Logger.detail(`Listener: ${listener.id}`);
if (process.env.NODE_ENV === 'production') {
captureException(error);
throw new Error(error.stack);
} else {
Logger.error(error.stack);
}
Logger.error(error.stack);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/listeners/mongodb/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ class MongodbErrorListener extends Listener {
}

public exec(error: Error): void {
captureException(error);
Logger.error('Oops, something went wrong with MongoDB!');
Logger.detail('Please make sure MongoDB is running.');
if (process.env.NODE_ENV === 'production') {
captureException(error);
throw new Error(error.stack);
} else {
Logger.error(error.stack);
}
Logger.error(error.stack);
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/listeners/process/uncaughtException.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { captureException } from '@sentry/node';
import { captureException, flush } from '@sentry/node';
import { Listener } from 'discord-akairo';
import Logger from '@/app/structures/Logger';

Expand All @@ -10,11 +10,13 @@ class UncaughtExceptionListener extends Listener {
});
}

public exec(error: Error): void {
public async exec(error: Error): Promise<void> {
captureException(error);
Logger.error('Oops, something went wrong with Swan! (uncaughtException)');
if (process.env.NODE_ENV === 'production') {
captureException(error);
throw new Error(error.stack);
await flush(5000);
// eslint-disable-next-line node/no-process-exit
process.exit(1);
} else {
Logger.error(error.stack);
Logger.warn('An uncaughtException just occurred. Swan is now in an undefined state. Continuing using it might lead to unforeseen and unpredictable issues.');
Expand Down
8 changes: 2 additions & 6 deletions src/listeners/process/unhandledRejection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ class UnhandledRejectionListener extends Listener {
}

public exec(error: Error): void {
captureException(error);
Logger.error('Oops, something went wrong with Swan! (unhandledRejection)');
if (process.env.NODE_ENV === 'production') {
captureException(error);
throw new Error(error.stack);
} else {
Logger.error(error.stack);
}
Logger.error(error.stack);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/listeners/taskHandler/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ class TaskHandlerErrorListener extends Listener {
}

public exec(error: Error, task: Task): void {
captureException(error);
Logger.error('Oops, something went wrong with a task!');
Logger.detail(`Task: ${task}`);
Logger.detail(`Cron: ${task.cron}`);
if (process.env.NODE_ENV === 'production') {
captureException(error);
throw new Error(error.stack);
} else {
Logger.error(error.stack);
}
Logger.error(error.stack);
}
}

Expand Down

0 comments on commit 4baff83

Please sign in to comment.