3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-08 03:27:20 +00:00

Fixes, refactoring and PR feedback

This commit is contained in:
Lily Bergonzat 2024-04-15 15:51:45 +02:00
parent 0be54912c4
commit 893a77d562
202 changed files with 1037 additions and 1069 deletions

View file

@ -4,6 +4,7 @@ import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
import { UsernameHistory } from "../../data/UsernameHistory";
import { NamesCmd } from "./commands/NamesCmd";
import { NameHistoryPluginType, zNameHistoryConfig } from "./types";
import { CommonPlugin } from "../Common/CommonPlugin";
const defaultOptions: PluginOptions<NameHistoryPluginType> = {
config: {
@ -44,4 +45,8 @@ export const NameHistoryPlugin = guildPlugin<NameHistoryPluginType>()({
state.usernameHistory = new UsernameHistory();
state.updateQueue = new Queue();
},
beforeStart(pluginData) {
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
},
});

View file

@ -21,7 +21,7 @@ export const NamesCmd = nameHistoryCmd({
const usernames = await pluginData.state.usernameHistory.getByUserId(args.userId);
if (nicknames.length === 0 && usernames.length === 0) {
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "No name history found");
void pluginData.state.common.sendErrorMessage(msg, "No name history found");
return;
}

View file

@ -1,8 +1,9 @@
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand, pluginUtils } from "knub";
import z from "zod";
import { Queue } from "../../Queue";
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
import { UsernameHistory } from "../../data/UsernameHistory";
import { CommonPlugin } from "../Common/CommonPlugin";
export const zNameHistoryConfig = z.strictObject({
can_view: z.boolean(),
@ -14,6 +15,7 @@ export interface NameHistoryPluginType extends BasePluginType {
nicknameHistory: GuildNicknameHistory;
usernameHistory: UsernameHistory;
updateQueue: Queue;
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
};
}