2020-07-21 01:02:42 +02:00
|
|
|
import { PluginOptions } from "knub";
|
|
|
|
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
2020-07-22 22:56:21 +03:00
|
|
|
import { ConfigSchema, PersistPluginType } from "./types";
|
2020-07-21 01:02:42 +02:00
|
|
|
import { GuildPersistedData } from "src/data/GuildPersistedData";
|
|
|
|
import { GuildLogs } from "src/data/GuildLogs";
|
|
|
|
import { StoreDataEvt } from "./events/StoreDataEvt";
|
|
|
|
import { LoadDataEvt } from "./events/LoadDataEvt";
|
|
|
|
|
|
|
|
const defaultOptions: PluginOptions<PersistPluginType> = {
|
|
|
|
config: {
|
|
|
|
persisted_roles: [],
|
|
|
|
persist_nicknames: false,
|
|
|
|
persist_voice_mutes: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const PersistPlugin = zeppelinPlugin<PersistPluginType>()("persist", {
|
|
|
|
configSchema: ConfigSchema,
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
|
events: [
|
|
|
|
StoreDataEvt,
|
|
|
|
LoadDataEvt,
|
|
|
|
],
|
|
|
|
|
|
|
|
onLoad(pluginData) {
|
|
|
|
const { state, guild } = pluginData;
|
|
|
|
|
|
|
|
state.persistedData = GuildPersistedData.getGuildInstance(guild.id);
|
|
|
|
state.logs = new GuildLogs(guild.id);
|
|
|
|
},
|
|
|
|
});
|