mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
WIP ModActions
This commit is contained in:
parent
a3d0ec03d9
commit
ebcb28261b
25 changed files with 1162 additions and 6 deletions
|
@ -7,6 +7,8 @@ import { GuildCases } from "../../data/GuildCases";
|
|||
import { createCaseNote } from "./functions/createCaseNote";
|
||||
import { Case } from "../../data/entities/Case";
|
||||
import { postCaseToCaseLogChannel } from "./functions/postToCaseLogChannel";
|
||||
import { CaseTypes } from "../../data/CaseTypes";
|
||||
import { getCaseTypeAmountForUserId } from "./functions/getCaseTypeAmountForUserId";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
@ -21,22 +23,28 @@ export const CasesPlugin = zeppelinPlugin<CasesPluginType>()("cases", {
|
|||
|
||||
public: {
|
||||
createCase(pluginData) {
|
||||
return async (args: CaseArgs) => {
|
||||
return (args: CaseArgs) => {
|
||||
return createCase(pluginData, args);
|
||||
};
|
||||
},
|
||||
|
||||
createCaseNote(pluginData) {
|
||||
return async (args: CaseNoteArgs) => {
|
||||
return (args: CaseNoteArgs) => {
|
||||
return createCaseNote(pluginData, args);
|
||||
};
|
||||
},
|
||||
|
||||
postCaseToCaseLogChannel(pluginData) {
|
||||
return async (caseOrCaseId: Case | number) => {
|
||||
return (caseOrCaseId: Case | number) => {
|
||||
return postCaseToCaseLogChannel(pluginData, caseOrCaseId);
|
||||
};
|
||||
},
|
||||
|
||||
getCaseTypeAmountForUserId(pluginData) {
|
||||
return (userID: string, type: CaseTypes) => {
|
||||
return getCaseTypeAmountForUserId(pluginData, userID, type);
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
onLoad(pluginData) {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import { PluginData } from "knub";
|
||||
import { CasesPluginType } from "../types";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
||||
export async function getCaseTypeAmountForUserId(
|
||||
pluginData: PluginData<CasesPluginType>,
|
||||
userID: string,
|
||||
type: CaseTypes,
|
||||
): Promise<number> {
|
||||
const cases = (await pluginData.state.cases.getByUserId(userID)).filter(c => !c.is_hidden);
|
||||
let typeAmount = 0;
|
||||
|
||||
if (cases.length > 0) {
|
||||
cases.forEach(singleCase => {
|
||||
if (singleCase.type === type.valueOf()) {
|
||||
typeAmount++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return typeAmount;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue