commit 7a5b368c661bad3d7a7c49fda8a74100a342dd6e
parent fd5c0a17532d4e9e37b5a4d6af341105463010f7
Author: Demonstrandum <moi@knutsen.co>
Date: Thu, 19 Mar 2020 16:59:21 +0000
Answer with errors.
Diffstat:
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/lib/commands/pp.ts b/lib/commands/pp.ts
@@ -5,7 +5,8 @@ export default home_scope => {
try {
user = message.mentions.users.first().id;
} finally {
- const shaft = '='.repeat(CONFIG.pp_sizes[user] || CONFIG.pp_sizes[user] = Math.ceil(Math.random() * 16));
+ const shaft = '='.repeat(CONFIG.pp_sizes[user]
+ || (CONFIG.pp_sizes[user] = Math.ceil(Math.random() * 16)));
message.answer(`8${shaft}>`);
}
};
diff --git a/lib/main.ts b/lib/main.ts
@@ -38,9 +38,9 @@ let CONFIG = deep_merge(
// CONFIG will eventually update to the online version.
pastebin_latest().then(res => {
- deep_merge(CONFIG, res);
+ CONFIG = deep_merge(CONFIG, res);
// Remove any duplicates.
- CONFIG = export_config(CONFIG, {});
+ CONFIG = export_config(CONFIG, { ugly: true });
CONFIG = JSON.parse(CONFIG);
// Precompile all regular-expressions in known places.
['respond', 'reject', 'replace']
@@ -552,26 +552,31 @@ export class SimpOMatic {
}
console.log('Message received:', message.content);
- const trimmed = message.content.trim();
- message.content = trimmed;
- // When finished expanding...
- this.expand(message).then(content => {
- if (content.length >= 2000) {
- message.answer("The expansion for that message was"
- + " over 2000 characters, what the fuck is wrong with you?");
- return;
- }
- message.content = content;
- console.log('Expanded message:', message.content);
-
- if (message.content[0] === CONFIG.commands.prefix) {
- console.log('Message type: command.');
- this.process_command(message);
- } else {
- console.log('Message type: generic.');
- this.process_generic(message);
- }
- });
+ try {
+ const trimmed = message.content.trim();
+ message.content = trimmed;
+ // When finished expanding...
+ this.expand(message).then(content => {
+ if (content.length >= 2000) {
+ message.answer("The expansion for that message was"
+ + " over 2000 characters, what the fuck is wrong with you?");
+ return;
+ }
+ message.content = content;
+ console.log('Expanded message:', message.content);
+
+ if (message.content[0] === CONFIG.commands.prefix) {
+ console.log('Message type: command.');
+ this.process_command(message);
+ } else {
+ console.log('Message type: generic.');
+ this.process_generic(message);
+ }
+ });
+ } catch (e) {
+ message.answer(`Something went very wrong (\`${e.message}\`):\n`
+ + `${e.stack}`.format('```'));
+ }
}
}