3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-13 13:25:03 +00:00

Add custom argument types for deep-resolved users/members, use these in some places. Deprecate unknownUser (constant) and replace with instances of UnknownUser (class).

This commit is contained in:
Dragory 2019-04-20 19:03:30 +03:00
parent 2d690da92b
commit ab83e83d42
6 changed files with 151 additions and 111 deletions

View file

@ -4,7 +4,7 @@ import yaml from "js-yaml";
import fs from "fs";
const fsp = fs.promises;
import { Knub, logger, PluginError, CommandArgumentTypeError, Plugin } from "knub";
import { Knub, logger, PluginError, Plugin } from "knub";
import { SimpleError } from "./SimpleError";
require("dotenv").config();
@ -74,8 +74,9 @@ import { AutoReactionsPlugin } from "./plugins/AutoReactionsPlugin";
import { PingableRolesPlugin } from "./plugins/PingableRolesPlugin";
import { SelfGrantableRolesPlugin } from "./plugins/SelfGrantableRolesPlugin";
import { RemindersPlugin } from "./plugins/Reminders";
import { convertDelayStringToMS, errorMessage, successMessage } from "./utils";
import { errorMessage, successMessage } from "./utils";
import { ZeppelinPlugin } from "./plugins/ZeppelinPlugin";
import { customArgumentTypes } from "./customArgumentTypes";
// Run latest database migrations
logger.info("Running database migrations");
@ -178,16 +179,7 @@ connect().then(async conn => {
threshold: 200,
},
customArgumentTypes: {
delay(value) {
const result = convertDelayStringToMS(value);
if (result == null) {
throw new CommandArgumentTypeError(`Could not convert ${value} to a delay`);
}
return result;
},
},
customArgumentTypes,
sendSuccessMessageFn(channel, body) {
channel.createMessage(successMessage(body));