2020-07-05 05:00:54 +03:00
|
|
|
import { utilityCmd } from "../types";
|
|
|
|
import { baseTypeHelpers as t } from "knub";
|
2020-07-05 15:59:15 +03:00
|
|
|
import { archiveSearch, displaySearch, SearchType } from "./search";
|
|
|
|
|
|
|
|
// Separate from SearchCmd to avoid a circular reference from ./search.ts
|
|
|
|
export const searchCmdSignature = {
|
|
|
|
query: t.string({ catchAll: true }),
|
|
|
|
|
|
|
|
page: t.number({ option: true, shortcut: "p" }),
|
|
|
|
role: t.string({ option: true, shortcut: "r" }),
|
|
|
|
voice: t.switchOption({ shortcut: "v" }),
|
|
|
|
bot: t.switchOption({ shortcut: "b" }),
|
|
|
|
sort: t.string({ option: true }),
|
|
|
|
"case-sensitive": t.switchOption({ shortcut: "cs" }),
|
|
|
|
export: t.switchOption({ shortcut: "e" }),
|
|
|
|
ids: t.switchOption(),
|
|
|
|
regex: t.switchOption({ shortcut: "re" }),
|
|
|
|
"status-search": t.switchOption({ shortcut: "ss" }),
|
|
|
|
};
|
2020-07-05 05:00:54 +03:00
|
|
|
|
2020-07-05 15:03:51 +03:00
|
|
|
export const SearchCmd = utilityCmd({
|
|
|
|
trigger: ["search", "s"],
|
2020-07-05 15:59:15 +03:00
|
|
|
description: "Search server members",
|
|
|
|
usage: "!search dragory",
|
|
|
|
permission: "can_search",
|
2020-07-05 15:03:51 +03:00
|
|
|
|
2020-07-05 15:59:15 +03:00
|
|
|
signature: searchCmdSignature,
|
2020-07-05 05:00:54 +03:00
|
|
|
|
2020-07-05 15:59:15 +03:00
|
|
|
run({ pluginData, message, args }) {
|
|
|
|
if (args.export) {
|
|
|
|
return archiveSearch(pluginData, args, SearchType.MemberSearch, message);
|
|
|
|
} else {
|
|
|
|
return displaySearch(pluginData, args, SearchType.MemberSearch, message);
|
|
|
|
}
|
2020-07-05 05:00:54 +03:00
|
|
|
},
|
2020-07-05 15:03:51 +03:00
|
|
|
});
|