commit f32aa125c47b812ffcb532a33280806ae2fbc319
parent 6e28917ee05bf0242ba42fa2c967bff38bf954fa
Author: Demonstrandum <moi@knutsen.co>
Date: Tue, 3 Nov 2020 22:33:09 +0000
Do not add punctuation if punctuation is already there.
Diffstat:
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/lib/default.ts b/lib/default.ts
@@ -26,7 +26,7 @@ const DEFAULT_GUILD_CONFIG : Types.Config = {
commands: {
prefix: '!',
max_history: 40,
- not_understood: "Command not understood",
+ not_understood: "Command not understood...",
aliases: {
'img': 'image',
'i': 'image',
diff --git a/lib/extensions.ts b/lib/extensions.ts
@@ -118,6 +118,7 @@ declare global {
interface String {
squeeze(): string;
capitalize(): string;
+ punctuation(): string | null;
leading_space(): string;
head(): string;
tail(): string;
@@ -197,6 +198,12 @@ String.prototype.capitalize = function () {
return this.charAt(0).toUpperCase() + this.slice(1);
};
+String.prototype.punctuation = function () {
+ const punct = ';.,?!'.split('');
+ const mark = this.trimEnd().slice(-1);
+ return punct.includes(mark) ? mark : null;
+}
+
String.prototype.emojify = function () { return `:${this}:`; };
String.prototype.head = Array.prototype.head as any;
diff --git a/lib/main.ts b/lib/main.ts
@@ -426,8 +426,10 @@ Would you like to slow down a little?`.squeeze());
\`${p}fork\`, and get started...`.squeeze());
break;
}
+
+ const has_punct = CONFIG.commands.not_understood.punctuation();
message.answer(`
- :warning: ${CONFIG.commands.not_understood}.
+ :warning: ${CONFIG.commands.not_understood}${has_punct?'':'.'}
> \`${CONFIG.commands.prefix}${operator}\``.squeeze());
break;
}