mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Migrate Post to new Plugin structure
This commit is contained in:
parent
ebcb28261b
commit
5c070643a3
15 changed files with 752 additions and 0 deletions
58
backend/src/plugins/Post/PostPlugin.ts
Normal file
58
backend/src/plugins/Post/PostPlugin.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { PluginOptions } from "knub";
|
||||
import { ConfigSchema, PostPluginType } from "./types";
|
||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
||||
import { GuildScheduledPosts } from "src/data/GuildScheduledPosts";
|
||||
import { GuildLogs } from "src/data/GuildLogs";
|
||||
import { PostCmd } from "./commands/PostCmd";
|
||||
import { PostEmbedCmd } from "./commands/PostEmbedCmd";
|
||||
import { EditCmd } from "./commands/EditCmd";
|
||||
import { EditEmbedCmd } from "./commands/EditEmbedCmd";
|
||||
import { ScheduledPostsShowCmd } from "./commands/ScheduledPostsShowCmd";
|
||||
import { ScheduledPostsListCmd } from "./commands/ScheduledPostsListCmd";
|
||||
import { ScheduledPostsDeleteCmd } from "./commands/SchedluedPostsDeleteCmd";
|
||||
import { scheduledPostLoop } from "./util/scheduledPostLoop";
|
||||
|
||||
const defaultOptions: PluginOptions<PostPluginType> = {
|
||||
config: {
|
||||
can_post: false,
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
level: ">=100",
|
||||
config: {
|
||||
can_post: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const PostPlugin = zeppelinPlugin<PostPluginType>()("post", {
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
commands: [
|
||||
PostCmd,
|
||||
PostEmbedCmd,
|
||||
EditCmd,
|
||||
EditEmbedCmd,
|
||||
ScheduledPostsShowCmd,
|
||||
ScheduledPostsListCmd,
|
||||
ScheduledPostsDeleteCmd,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
||||
state.scheduledPosts = GuildScheduledPosts.getGuildInstance(guild.id);
|
||||
state.logs = new GuildLogs(guild.id);
|
||||
|
||||
scheduledPostLoop(pluginData);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
clearTimeout(pluginData.state.scheduledPostLoopTimeout);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue