counters: add !counter view command

This commit is contained in:
Dragory 2021-02-13 22:08:38 +02:00
parent 78ff2641d4
commit 91fde47c97
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
4 changed files with 153 additions and 1 deletions

View file

@ -14,14 +14,32 @@ import { initCounterTrigger } from "./functions/initCounterTrigger";
import { decayCounter } from "./functions/decayCounter";
import { validateCondition } from "./functions/validateCondition";
import { StrictValidationError } from "../../validatorUtils";
import { PluginOptions } from "knub";
import { ViewCounterCmd } from "./commands/ViewCounterCmd";
const MAX_COUNTERS = 5;
const DECAY_APPLY_INTERVAL = 5 * MINUTES;
const defaultOptions = {
const defaultOptions: PluginOptions<CountersPluginType> = {
config: {
counters: {},
can_view: false,
can_edit: false,
},
overrides: [
{
level: ">=50",
config: {
can_view: true,
},
},
{
level: ">=100",
config: {
can_edit: true,
},
},
],
};
const configPreprocessor: ConfigPreprocessorFn<CountersPluginType> = options => {
@ -69,6 +87,8 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()("counter
offCounterEvent: mapToPublicFn(offCounterEvent),
},
commands: [ViewCounterCmd],
async onLoad(pluginData) {
pluginData.state.counters = new GuildCounters(pluginData.guild.id);
pluginData.state.events = new EventEmitter();