2020-07-21 01:02:42 +02:00
|
|
|
import { PluginOptions } from "knub";
|
2020-10-01 01:43:38 +03:00
|
|
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
2020-07-22 22:56:21 +03:00
|
|
|
import { ConfigSchema, PersistPluginType } from "./types";
|
2020-10-01 01:43:38 +03:00
|
|
|
import { GuildPersistedData } from "../../data/GuildPersistedData";
|
|
|
|
import { GuildLogs } from "../../data/GuildLogs";
|
2020-07-21 01:02:42 +02:00
|
|
|
import { StoreDataEvt } from "./events/StoreDataEvt";
|
|
|
|
import { LoadDataEvt } from "./events/LoadDataEvt";
|
2020-07-30 13:08:06 +03:00
|
|
|
import { trimPluginDescription } from "../../utils";
|
2020-08-21 03:58:49 +03:00
|
|
|
import { LogsPlugin } from "../Logs/LogsPlugin";
|
2020-07-21 01:02:42 +02:00
|
|
|
|
|
|
|
const defaultOptions: PluginOptions<PersistPluginType> = {
|
|
|
|
config: {
|
|
|
|
persisted_roles: [],
|
|
|
|
persist_nicknames: false,
|
|
|
|
persist_voice_mutes: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-05-23 14:35:16 +03:00
|
|
|
export const PersistPlugin = zeppelinGuildPlugin<PersistPluginType>()({
|
|
|
|
name: "persist",
|
2020-07-30 13:08:06 +03:00
|
|
|
showInDocs: true,
|
|
|
|
info: {
|
|
|
|
prettyName: "Persist",
|
|
|
|
description: trimPluginDescription(`
|
|
|
|
Re-apply roles or nicknames for users when they rejoin the server.
|
|
|
|
Mute roles are re-applied automatically, this plugin is not required for that.
|
|
|
|
`),
|
|
|
|
},
|
|
|
|
|
2020-08-21 03:58:49 +03:00
|
|
|
dependencies: [LogsPlugin],
|
2020-07-21 01:02:42 +02:00
|
|
|
configSchema: ConfigSchema,
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
|
events: [
|
|
|
|
StoreDataEvt,
|
|
|
|
LoadDataEvt,
|
|
|
|
],
|
|
|
|
|
2021-05-23 14:35:16 +03:00
|
|
|
afterLoad(pluginData) {
|
2020-07-21 01:02:42 +02:00
|
|
|
const { state, guild } = pluginData;
|
|
|
|
|
|
|
|
state.persistedData = GuildPersistedData.getGuildInstance(guild.id);
|
|
|
|
state.logs = new GuildLogs(guild.id);
|
|
|
|
},
|
|
|
|
});
|