Add a format property that can be returned to not format the message

This commit is contained in:
Oliver Akins 2022-08-20 14:28:52 -06:00
parent 3f5a122bae
commit a92722bdf6
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -59,6 +59,7 @@ const subcommands: {[index: string]: any} = {
if (!message?.includes(`$(count)`)) {
return {
message: `Can't create a counter when the message doesn't have $(count) in it somewhere`,
format: false,
};
};
@ -150,7 +151,7 @@ const route: ServerRoute = {
};
try {
var { message, value } = await sc.handler(
var { message, value=0, format=true } = await sc.handler(
request,
{ channel, user },
args
@ -160,6 +161,9 @@ const route: ServerRoute = {
};
if (message) {
if (!format) {
return message;
};
return message.replace(/\$\(count\)/g, value);
} else if (value) {
return value;