2020-07-21 00:10:09 +02:00
|
|
|
import { PluginOptions } from "knub";
|
2020-07-22 22:56:21 +03:00
|
|
|
import { ConfigSchema, NameHistoryPluginType } from "./types";
|
2020-10-01 01:43:38 +03:00
|
|
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
|
|
|
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
|
|
|
|
import { UsernameHistory } from "../../data/UsernameHistory";
|
|
|
|
import { Queue } from "../../Queue";
|
2020-07-21 00:10:09 +02:00
|
|
|
import { NamesCmd } from "./commands/NamesCmd";
|
|
|
|
import { ChannelJoinEvt, MessageCreateEvt } from "./events/UpdateNameEvts";
|
|
|
|
|
|
|
|
const defaultOptions: PluginOptions<NameHistoryPluginType> = {
|
|
|
|
config: {
|
|
|
|
can_view: false,
|
|
|
|
},
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
level: ">=50",
|
|
|
|
config: {
|
|
|
|
can_view: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2021-05-23 14:35:16 +03:00
|
|
|
export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()({
|
|
|
|
name: "name_history",
|
2020-07-30 13:08:06 +03:00
|
|
|
showInDocs: false,
|
|
|
|
|
2020-07-21 00:10:09 +02:00
|
|
|
configSchema: ConfigSchema,
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
|
commands: [
|
|
|
|
NamesCmd,
|
|
|
|
],
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
|
events: [
|
|
|
|
ChannelJoinEvt,
|
|
|
|
MessageCreateEvt,
|
|
|
|
],
|
|
|
|
|
2021-05-23 17:13:11 +03:00
|
|
|
beforeLoad(pluginData) {
|
2020-07-21 00:10:09 +02:00
|
|
|
const { state, guild } = pluginData;
|
|
|
|
|
|
|
|
state.nicknameHistory = GuildNicknameHistory.getGuildInstance(guild.id);
|
|
|
|
state.usernameHistory = new UsernameHistory();
|
|
|
|
state.updateQueue = new Queue();
|
|
|
|
},
|
|
|
|
});
|