2020-07-20 00:23:47 +02:00
|
|
|
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
2020-07-22 22:56:21 +03:00
|
|
|
import { AutoReactionsPluginType, ConfigSchema } from "./types";
|
2020-07-20 00:23:47 +02:00
|
|
|
import { PluginOptions } from "knub";
|
|
|
|
import { NewAutoReactionsCmd } from "./commands/NewAutoReactionsCmd";
|
|
|
|
import { DisableAutoReactionsCmd } from "./commands/DisableAutoReactionsCmd";
|
|
|
|
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
|
|
|
import { GuildAutoReactions } from "src/data/GuildAutoReactions";
|
2020-07-21 17:55:25 +02:00
|
|
|
import { AddReactionsEvt } from "./events/AddReactionsEvt";
|
2020-07-30 13:08:06 +03:00
|
|
|
import { trimPluginDescription } from "../../utils";
|
2020-07-20 00:23:47 +02:00
|
|
|
|
|
|
|
const defaultOptions: PluginOptions<AutoReactionsPluginType> = {
|
|
|
|
config: {
|
|
|
|
can_manage: false,
|
|
|
|
},
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
level: ">=100",
|
|
|
|
config: {
|
|
|
|
can_manage: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AutoReactionsPlugin = zeppelinPlugin<AutoReactionsPluginType>()("auto_reactions", {
|
2020-07-30 13:08:06 +03:00
|
|
|
showInDocs: true,
|
|
|
|
info: {
|
|
|
|
prettyName: "Auto-reactions",
|
|
|
|
description: trimPluginDescription(`
|
|
|
|
Allows setting up automatic reactions to all new messages on a channel
|
|
|
|
`),
|
|
|
|
},
|
|
|
|
|
2020-07-20 00:23:47 +02:00
|
|
|
configSchema: ConfigSchema,
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
|
commands: [
|
|
|
|
NewAutoReactionsCmd,
|
|
|
|
DisableAutoReactionsCmd,
|
|
|
|
],
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
|
events: [
|
2020-07-21 17:55:25 +02:00
|
|
|
AddReactionsEvt,
|
2020-07-20 00:23:47 +02:00
|
|
|
],
|
|
|
|
|
|
|
|
onLoad(pluginData) {
|
|
|
|
const { state, guild } = pluginData;
|
|
|
|
|
|
|
|
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
|
|
|
state.autoReactions = GuildAutoReactions.getGuildInstance(guild.id);
|
|
|
|
},
|
|
|
|
});
|