3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Update to new Knub 30 beta. Code clean-up.

This commit is contained in:
Dragory 2020-10-01 01:43:38 +03:00
parent 5d579446c5
commit 2f470dc37a
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
299 changed files with 1075 additions and 1004 deletions

View file

@ -1,4 +1,4 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { CaseArgs, CaseNoteArgs, CasesPluginType, ConfigSchema } from "./types";
import { createCase } from "./functions/createCase";
import { GuildLogs } from "../../data/GuildLogs";
@ -26,7 +26,7 @@ const defaultOptions = {
},
};
export const CasesPlugin = zeppelinPlugin<CasesPluginType>()("cases", {
export const CasesPlugin = zeppelinGuildPlugin<CasesPluginType>()("cases", {
showInDocs: true,
info: {
prettyName: "Cases",

View file

@ -1,11 +1,11 @@
import { CaseArgs, CasesPluginType } from "../types";
import { resolveUser } from "../../../utils";
import { plugin, PluginData } from "knub";
import { GuildPluginData } from "knub";
import { createCaseNote } from "./createCaseNote";
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
import { logger } from "../../../logger";
export async function createCase(pluginData: PluginData<CasesPluginType>, args: CaseArgs) {
export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) {
const user = await resolveUser(pluginData.client, args.userId);
const userName = `${user.username}#${user.discriminator}`;

View file

@ -1,11 +1,11 @@
import { CaseNoteArgs, CasesPluginType } from "../types";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
import { resolveCaseId } from "./resolveCaseId";
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
import { resolveUser } from "../../../utils";
export async function createCaseNote(pluginData: PluginData<CasesPluginType>, args: CaseNoteArgs): Promise<void> {
export async function createCaseNote(pluginData: GuildPluginData<CasesPluginType>, args: CaseNoteArgs): Promise<void> {
const theCase = await pluginData.state.cases.find(resolveCaseId(args.caseId));
if (!theCase) {
throw new RecoverablePluginError(ERRORS.UNKNOWN_NOTE_CASE);

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { CaseTypes, CaseTypeToName } from "../../../data/CaseTypes";
import { caseColors } from "../caseColors";
export function getCaseColor(pluginData: PluginData<CasesPluginType>, caseType: CaseTypes) {
export function getCaseColor(pluginData: GuildPluginData<CasesPluginType>, caseType: CaseTypes) {
return pluginData.config.get().case_colors?.[CaseTypeToName[caseType]] ?? caseColors[caseType];
}

View file

@ -2,7 +2,7 @@ import { Case } from "../../../data/entities/Case";
import { AdvancedMessageContent, MessageContent } from "eris";
import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes";
import { PluginData, helpers } from "knub";
import { GuildPluginData, helpers } from "knub";
import { CasesPluginType } from "../types";
import { resolveCaseId } from "./resolveCaseId";
import { chunkLines, chunkMessageLines, emptyEmbedValue, messageLink } from "../../../utils";
@ -10,7 +10,7 @@ import { getCaseColor } from "./getCaseColor";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
export async function getCaseEmbed(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
caseOrCaseId: Case | number,
requestMemberId?: string,
): Promise<AdvancedMessageContent> {

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { CaseTypes, CaseTypeToName } from "../../../data/CaseTypes";
import { caseIcons } from "../caseIcons";
export function getCaseIcon(pluginData: PluginData<CasesPluginType>, caseType: CaseTypes) {
export function getCaseIcon(pluginData: GuildPluginData<CasesPluginType>, caseType: CaseTypes) {
return pluginData.config.get().case_icons?.[CaseTypeToName[caseType]] ?? caseIcons[caseType];
}

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import {
convertDelayStringToMS,
@ -24,7 +24,7 @@ const UPDATE_STR = "**[Update]**";
const RELATIVE_TIME_THRESHOLD = 7 * DAYS;
export async function getCaseSummary(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
caseOrCaseId: Case | number,
withLinks = false,
requestMemberId?: string,

View file

@ -1,9 +1,9 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { CaseTypes } from "../../../data/CaseTypes";
export async function getCaseTypeAmountForUserId(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
userID: string,
type: CaseTypes,
): Promise<number> {

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { Message, MessageContent, MessageFile, TextChannel } from "eris";
import { isDiscordRESTError } from "../../../utils";
@ -9,7 +9,7 @@ import { resolveCaseId } from "./resolveCaseId";
import { logger } from "../../../logger";
export async function postToCaseLogChannel(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
content: MessageContent,
file: MessageFile = null,
): Promise<Message | null> {
@ -40,7 +40,7 @@ export async function postToCaseLogChannel(
}
export async function postCaseToCaseLogChannel(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
caseOrCaseId: Case | number,
): Promise<Message | null> {
const theCase = await pluginData.state.cases.find(resolveCaseId(caseOrCaseId));

View file

@ -1,7 +1,7 @@
import * as t from "io-ts";
import { tDelayString, tPartialDictionary, tNullable } from "../../utils";
import { CaseNameToType, CaseTypes } from "../../data/CaseTypes";
import { BasePluginType } from "knub";
import { BasePluginType, guildCommand, guildEventListener } from "knub";
import { GuildLogs } from "../../data/GuildLogs";
import { GuildCases } from "../../data/GuildCases";
import { GuildArchives } from "../../data/GuildArchives";