mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-19 08:05:01 +00:00
Reorganize project. Add folder for shared code between backend/dashboard. Switch from jest to ava for tests.
This commit is contained in:
parent
cd53d3ce5d
commit
9250c84637
162 changed files with 11056 additions and 9900 deletions
49
backend/src/customArgumentTypes.ts
Normal file
49
backend/src/customArgumentTypes.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import {
|
||||
convertDelayStringToMS,
|
||||
deactivateMentions,
|
||||
disableCodeBlocks,
|
||||
resolveMember,
|
||||
resolveUser,
|
||||
UnknownUser,
|
||||
} from "./utils";
|
||||
import { Client, GuildChannel, Message } from "eris";
|
||||
import { ICommandContext, TypeConversionError } from "knub";
|
||||
|
||||
export const customArgumentTypes = {
|
||||
delay(value) {
|
||||
const result = convertDelayStringToMS(value);
|
||||
if (result == null) {
|
||||
throw new TypeConversionError(`Could not convert ${value} to a delay`);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
async resolvedUser(value, context: ICommandContext) {
|
||||
const result = await resolveUser(context.bot, value);
|
||||
if (result == null || result instanceof UnknownUser) {
|
||||
throw new TypeConversionError(`User \`${disableCodeBlocks(value)}\` was not found`);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
async resolvedUserLoose(value, context: ICommandContext) {
|
||||
const result = await resolveUser(context.bot, value);
|
||||
if (result == null) {
|
||||
throw new TypeConversionError(`Invalid user: \`${disableCodeBlocks(value)}\``);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
async resolvedMember(value, context: ICommandContext) {
|
||||
if (!(context.message.channel instanceof GuildChannel)) return null;
|
||||
|
||||
const result = await resolveMember(context.bot, context.message.channel.guild, value);
|
||||
if (result == null) {
|
||||
throw new TypeConversionError(
|
||||
`Member \`${disableCodeBlocks(value)}\` was not found or they have left the server`,
|
||||
);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue