mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
dumb commit for @almeidx to see why this is stupid
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
1a8027de16
commit
baff82015c
40 changed files with 173 additions and 71 deletions
|
@ -60,4 +60,7 @@ export const AutoDeletePlugin = zeppelinGuildPlugin<AutoDeletePluginType>()({
|
|||
pluginData.state.guildSavedMessages.events.off("delete", pluginData.state.onMessageDeleteFn);
|
||||
pluginData.state.guildSavedMessages.events.off("deleteBulk", pluginData.state.onMessageDeleteBulkFn);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -57,4 +57,7 @@ export const AutoReactionsPlugin = zeppelinGuildPlugin<AutoReactionsPluginType>(
|
|||
pluginData.state.autoReactions = GuildAutoReactions.getGuildInstance(pluginData.guild.id);
|
||||
pluginData.state.cache = new Map();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -65,12 +65,12 @@ const defaultOptions = {
|
|||
* Config preprocessor to set default values for triggers and perform extra validation
|
||||
*/
|
||||
|
||||
const configParser: ConfigParserFn<AutomodPluginType> = (options) => {
|
||||
if (options.config?.rules) {
|
||||
const configParser = (options) => {
|
||||
if (options.rules) {
|
||||
// Loop through each rule
|
||||
for (const [name, rule] of Object.entries(options.config.rules)) {
|
||||
for (const [name, rule] of Object.entries(options.rules)) {
|
||||
if (rule == null) {
|
||||
delete options.config.rules[name];
|
||||
delete options.rules[name];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ const configParser: ConfigParserFn<AutomodPluginType> = (options) => {
|
|||
for (const triggerObj of rule["triggers"]) {
|
||||
for (const triggerName in triggerObj) {
|
||||
if (!availableTriggers[triggerName]) {
|
||||
throw new StrictValidationError([`Unknown trigger '${triggerName}' in rule '${rule.name}'`]);
|
||||
throw new StrictValidationError([`Unknown trigger '${triggerName}' in rule '${rule["name"]}'`]);
|
||||
}
|
||||
|
||||
const triggerBlueprint = availableTriggers[triggerName];
|
||||
|
@ -118,11 +118,11 @@ const configParser: ConfigParserFn<AutomodPluginType> = (options) => {
|
|||
|
||||
if (white && black) {
|
||||
throw new StrictValidationError([
|
||||
`Cannot have both blacklist and whitelist enabled at rule <${rule.name}/match_attachment_type>`,
|
||||
`Cannot have both blacklist and whitelist enabled at rule <${rule["name"]}/match_attachment_type>`,
|
||||
]);
|
||||
} else if (!white && !black) {
|
||||
throw new StrictValidationError([
|
||||
`Must have either blacklist or whitelist enabled at rule <${rule.name}/match_attachment_type>`,
|
||||
`Must have either blacklist or whitelist enabled at rule <${rule["name"]}/match_attachment_type>`,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -133,11 +133,11 @@ const configParser: ConfigParserFn<AutomodPluginType> = (options) => {
|
|||
|
||||
if (white && black) {
|
||||
throw new StrictValidationError([
|
||||
`Cannot have both blacklist and whitelist enabled at rule <${rule.name}/match_mime_type>`,
|
||||
`Cannot have both blacklist and whitelist enabled at rule <${rule["name"]}/match_mime_type>`,
|
||||
]);
|
||||
} else if (!white && !black) {
|
||||
throw new StrictValidationError([
|
||||
`Must have either blacklist or whitelist enabled at rule <${rule.name}/match_mime_type>`,
|
||||
`Must have either blacklist or whitelist enabled at rule <${rule["name"]}/match_mime_type>`,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ const configParser: ConfigParserFn<AutomodPluginType> = (options) => {
|
|||
if (rule["actions"]) {
|
||||
for (const actionName in rule["actions"]) {
|
||||
if (!availableActions[actionName]) {
|
||||
throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule.name}'`]);
|
||||
throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule["name"]}'`]);
|
||||
}
|
||||
|
||||
const actionBlueprint = availableActions[actionName];
|
||||
|
@ -164,9 +164,9 @@ const configParser: ConfigParserFn<AutomodPluginType> = (options) => {
|
|||
|
||||
// Enable logging of automod actions by default
|
||||
if (rule["actions"]) {
|
||||
for (const actionName in rule.actions) {
|
||||
for (const actionName in rule["actions"]) {
|
||||
if (!availableActions[actionName]) {
|
||||
throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule.name}'`]);
|
||||
throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule["name"]}'`]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ const configParser: ConfigParserFn<AutomodPluginType> = (options) => {
|
|||
rule["actions"]["log"] = true;
|
||||
}
|
||||
if (rule["actions"]["clean"] && rule["actions"]["start_thread"]) {
|
||||
throw new StrictValidationError([`Cannot have both clean and start_thread at rule '${rule.name}'`]);
|
||||
throw new StrictValidationError([`Cannot have both clean and start_thread at rule '${rule["name"]}'`]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,4 +80,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -85,4 +85,7 @@ export const CasesPlugin = zeppelinGuildPlugin<CasesPluginType>()({
|
|||
pluginData.state.archives = GuildArchives.getGuildInstance(pluginData.guild.id);
|
||||
pluginData.state.cases = GuildCases.getGuildInstance(pluginData.guild.id);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -84,4 +84,7 @@ export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()({
|
|||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
||||
pluginData.state.savedMessages.events.off("update", pluginData.state.onMessageUpdateFn);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -15,4 +15,7 @@ export const ChannelArchiverPlugin = zeppelinGuildPlugin<ChannelArchiverPluginTy
|
|||
messageCommands: [
|
||||
ArchiveChannelCmd,
|
||||
],
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -37,4 +37,7 @@ export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPlug
|
|||
afterLoad(pluginData) {
|
||||
pluginData.state.serverLogs = new GuildLogs(pluginData.guild.id);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -53,4 +53,7 @@ export const ContextMenuPlugin = zeppelinGuildPlugin<ContextMenuPluginType>()({
|
|||
afterLoad(pluginData) {
|
||||
loadAllCommands(pluginData);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -55,47 +55,6 @@ const defaultOptions: PluginOptions<CountersPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
// TODO: Fix `any` typing
|
||||
const configParser: ConfigParserFn<CountersPluginType> = (options: any) => {
|
||||
for (const [counterName, counter] of Object.entries(options.config?.counters || {})) {
|
||||
counter.name = counterName;
|
||||
counter.per_user = counter.per_user ?? false;
|
||||
counter.per_channel = counter.per_channel ?? false;
|
||||
counter.initial_value = counter.initial_value ?? 0;
|
||||
counter.triggers = counter.triggers || {};
|
||||
|
||||
if (Object.values(counter.triggers).length > MAX_TRIGGERS_PER_COUNTER) {
|
||||
throw new StrictValidationError([`You can only have at most ${MAX_TRIGGERS_PER_COUNTER} triggers per counter`]);
|
||||
}
|
||||
|
||||
// Normalize triggers
|
||||
for (const [triggerName, trigger] of Object.entries(counter.triggers)) {
|
||||
const triggerObj: Partial<TTrigger> = typeof trigger === "string" ? { condition: trigger } : trigger;
|
||||
|
||||
triggerObj.name = triggerName;
|
||||
const parsedCondition = parseCounterConditionString(triggerObj.condition || "");
|
||||
if (!parsedCondition) {
|
||||
throw new StrictValidationError([
|
||||
`Invalid comparison in counter trigger ${counterName}/${triggerName}: "${triggerObj.condition}"`,
|
||||
]);
|
||||
}
|
||||
|
||||
triggerObj.condition = buildCounterConditionString(parsedCondition[0], parsedCondition[1]);
|
||||
triggerObj.reverse_condition =
|
||||
triggerObj.reverse_condition ||
|
||||
buildCounterConditionString(getReverseCounterComparisonOp(parsedCondition[0]), parsedCondition[1]);
|
||||
|
||||
counter.triggers[triggerName] = triggerObj as TTrigger;
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.values(options.config?.counters || {}).length > MAX_COUNTERS) {
|
||||
throw new StrictValidationError([`You can only have at most ${MAX_COUNTERS} counters`]);
|
||||
}
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
/**
|
||||
* The Counters plugin keeps track of simple integer values that are tied to a user, channel, both, or neither — "counters".
|
||||
* These values can be changed using the functions in the plugin's public interface.
|
||||
|
@ -118,7 +77,46 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
|
|||
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
configParser,
|
||||
configParser: (options) => {
|
||||
for (const [counterName, counter] of Object.entries(options.counters || {})) {
|
||||
counter.name = counterName;
|
||||
counter.per_user = counter.per_user ?? false;
|
||||
counter.per_channel = counter.per_channel ?? false;
|
||||
counter.initial_value = counter.initial_value ?? 0;
|
||||
counter.triggers = counter.triggers || {};
|
||||
|
||||
if (Object.values(counter.triggers).length > MAX_TRIGGERS_PER_COUNTER) {
|
||||
throw new StrictValidationError([`You can only have at most ${MAX_TRIGGERS_PER_COUNTER} triggers per counter`]);
|
||||
}
|
||||
|
||||
// Normalize triggers
|
||||
for (const [triggerName, trigger] of Object.entries(counter.triggers)) {
|
||||
const triggerObj: Partial<TTrigger> = typeof trigger === "string" ? { condition: trigger } : trigger;
|
||||
|
||||
triggerObj.name = triggerName;
|
||||
const parsedCondition = parseCounterConditionString(triggerObj.condition || "");
|
||||
if (!parsedCondition) {
|
||||
throw new StrictValidationError([
|
||||
`Invalid comparison in counter trigger ${counterName}/${triggerName}: "${triggerObj.condition}"`,
|
||||
]);
|
||||
}
|
||||
|
||||
triggerObj.condition = buildCounterConditionString(parsedCondition[0], parsedCondition[1]);
|
||||
triggerObj.reverse_condition =
|
||||
triggerObj.reverse_condition ||
|
||||
buildCounterConditionString(getReverseCounterComparisonOp(parsedCondition[0]), parsedCondition[1]);
|
||||
|
||||
counter.triggers[triggerName] = triggerObj as TTrigger;
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.values(options.counters || {}).length > MAX_COUNTERS) {
|
||||
throw new StrictValidationError([`You can only have at most ${MAX_COUNTERS} counters`]);
|
||||
}
|
||||
|
||||
// FIXME: Any typing
|
||||
return <any>options;
|
||||
},
|
||||
|
||||
public: {
|
||||
counterExists: mapToPublicFn(counterExists),
|
||||
|
|
|
@ -66,4 +66,7 @@ export const CustomEventsPlugin = zeppelinGuildPlugin<CustomEventsPluginType>()(
|
|||
beforeUnload() {
|
||||
// TODO: Run clearTriggers() once we actually have something there
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -57,4 +57,7 @@ export const GuildAccessMonitorPlugin = zeppelinGlobalPlugin<GuildAccessMonitorP
|
|||
checkGuild(pluginData, guild);
|
||||
}
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -23,4 +23,7 @@ export const GuildConfigReloaderPlugin = zeppelinGlobalPlugin<GuildConfigReloade
|
|||
clearTimeout(pluginData.state.nextCheckTimeout);
|
||||
pluginData.state.unloaded = true;
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -30,6 +30,9 @@ export const GuildInfoSaverPlugin = zeppelinGuildPlugin<GuildInfoSaverPluginType
|
|||
beforeUnload(pluginData) {
|
||||
clearInterval(pluginData.state.updateInterval);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
||||
async function updateGuildInfo(guild: Guild) {
|
||||
|
|
|
@ -31,4 +31,7 @@ export const InternalPosterPlugin = zeppelinGuildPlugin<InternalPosterPluginType
|
|||
pluginData.state.missingPermissions = false;
|
||||
pluginData.state.webhookClientCache = new Map();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -74,4 +74,7 @@ export const LocateUserPlugin = zeppelinGuildPlugin<LocateUserPluginType>()({
|
|||
beforeUnload(pluginData) {
|
||||
pluginData.state.unregisterGuildEventListener?.();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -324,4 +324,7 @@ export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()({
|
|||
}
|
||||
discardRegExpRunner(`guild-${pluginData.guild.id}`);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -45,4 +45,7 @@ export const MessageSaverPlugin = zeppelinGuildPlugin<MessageSaverPluginType>()(
|
|||
const { state, guild } = pluginData;
|
||||
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -219,4 +219,7 @@ export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()({
|
|||
pluginData.state.unregisterGuildEventListener?.();
|
||||
pluginData.state.events.removeAllListeners();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -122,4 +122,7 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
|
|||
pluginData.state.unregisterGuildEventListener?.();
|
||||
pluginData.state.events.removeAllListeners();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -46,4 +46,7 @@ export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()({
|
|||
state.usernameHistory = new UsernameHistory();
|
||||
state.updateQueue = new Queue();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -43,4 +43,7 @@ export const PersistPlugin = zeppelinGuildPlugin<PersistPluginType>()({
|
|||
state.persistedData = GuildPersistedData.getGuildInstance(guild.id);
|
||||
state.logs = new GuildLogs(guild.id);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -47,4 +47,7 @@ export const PhishermanPlugin = zeppelinGuildPlugin<PhishermanPluginType>()({
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -49,4 +49,7 @@ export const PingableRolesPlugin = zeppelinGuildPlugin<PingableRolesPluginType>(
|
|||
state.cache = new Map();
|
||||
state.timeouts = new Map();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -69,4 +69,7 @@ export const PostPlugin = zeppelinGuildPlugin<PostPluginType>()({
|
|||
beforeUnload(pluginData) {
|
||||
pluginData.state.unregisterGuildEventListener?.();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -83,4 +83,7 @@ export const ReactionRolesPlugin = zeppelinGuildPlugin<ReactionRolesPluginType>(
|
|||
clearTimeout(pluginData.state.autoRefreshTimeout);
|
||||
}
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -59,4 +59,7 @@ export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()({
|
|||
pluginData.state.unregisterGuildEventListener?.();
|
||||
pluginData.state.unloaded = true;
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -34,9 +34,9 @@ export const RoleButtonsPlugin = zeppelinGuildPlugin<RoleButtonsPluginType>()({
|
|||
|
||||
configParser(options) {
|
||||
// Auto-fill "name" property for buttons based on the object key
|
||||
const buttonsArray = Array.isArray(options.config?.buttons) ? options.config.buttons : [];
|
||||
const buttonsArray = Array.isArray(options.buttons) ? options.buttons : [];
|
||||
const seenMessages = new Set();
|
||||
for (const [name, buttonsConfig] of Object.entries(options.config?.buttons ?? {})) {
|
||||
for (const [name, buttonsConfig] of Object.entries(options.buttons ?? {})) {
|
||||
if (name.length > 16) {
|
||||
throw new StrictValidationError(["Name for role buttons can be at most 16 characters long"]);
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ export const RoleButtonsPlugin = zeppelinGuildPlugin<RoleButtonsPluginType>()({
|
|||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
// FIXME: any typing lol
|
||||
return <any>options;
|
||||
},
|
||||
|
||||
dependencies: () => [LogsPlugin, RoleManagerPlugin],
|
||||
|
|
|
@ -36,4 +36,7 @@ export const RoleManagerPlugin = zeppelinGuildPlugin<RoleManagerPluginType>()({
|
|||
pluginData.state.abortRoleAssignmentLoop = true;
|
||||
await pluginData.state.pendingRoleAssignmentPromise;
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -58,4 +58,7 @@ export const RolesPlugin = zeppelinGuildPlugin<RolesPluginType>()({
|
|||
|
||||
state.logs = new GuildLogs(guild.id);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -71,7 +71,7 @@ export const SelfGrantableRolesPlugin = zeppelinGuildPlugin<SelfGrantableRolesPl
|
|||
},
|
||||
|
||||
configParser: (options) => {
|
||||
const config = options.config;
|
||||
const config = options;
|
||||
for (const [key, entry] of Object.entries(config.entries)) {
|
||||
// Apply default entry config
|
||||
config.entries[key] = { ...defaultSelfGrantableRoleEntry, ...entry };
|
||||
|
|
|
@ -82,4 +82,7 @@ export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()({
|
|||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
||||
clearInterval(pluginData.state.clearInterval);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -90,4 +90,7 @@ export const SpamPlugin = zeppelinGuildPlugin<SpamPluginType>()({
|
|||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
||||
clearInterval(pluginData.state.expiryInterval);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -125,13 +125,14 @@ export const StarboardPlugin = zeppelinGuildPlugin<StarboardPluginType>()({
|
|||
},
|
||||
|
||||
configParser(options) {
|
||||
if (options.config?.boards) {
|
||||
for (const [name, opts] of Object.entries(options.config.boards)) {
|
||||
options.config.boards[name] = Object.assign({}, defaultStarboardOpts, options.config.boards[name]);
|
||||
if (options.boards) {
|
||||
for (const [name, opts] of Object.entries(options.boards)) {
|
||||
options.boards[name] = Object.assign({}, defaultStarboardOpts, options.boards[name]);
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
// FIXME: any typing lol
|
||||
return <any>options;
|
||||
},
|
||||
|
||||
// prettier-ignore
|
||||
|
|
|
@ -97,16 +97,16 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
|
|||
},
|
||||
|
||||
configParser(options) {
|
||||
if (options.config.delete_with_command && options.config.auto_delete_command) {
|
||||
if (options.delete_with_command && options.auto_delete_command) {
|
||||
throw new StrictValidationError([
|
||||
`Cannot have both (global) delete_with_command and global_delete_invoke enabled`,
|
||||
]);
|
||||
}
|
||||
|
||||
// Check each category for conflicting options
|
||||
if (options.config?.categories) {
|
||||
for (const [name, opts] of Object.entries(options.config.categories)) {
|
||||
const cat = options.config.categories[name];
|
||||
if (options.categories) {
|
||||
for (const [name, opts] of Object.entries(options.categories)) {
|
||||
const cat = options.categories[name];
|
||||
if (cat.delete_with_command && cat.auto_delete_command) {
|
||||
throw new StrictValidationError([
|
||||
`Cannot have both (category specific) delete_with_command and category_delete_invoke enabled at <categories/${name}>`,
|
||||
|
@ -115,7 +115,8 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
|
|||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
// FIXME: any typing lol
|
||||
return <any>options;
|
||||
},
|
||||
|
||||
beforeLoad(pluginData) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { PluginOptions } from "knub";
|
||||
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones";
|
||||
import { mapToPublicFn } from "../../pluginUtils";
|
||||
import { getPluginConfigParser, mapToPublicFn } from "../../pluginUtils";
|
||||
import { trimPluginDescription } from "../../utils";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { ResetTimezoneCmd } from "./commands/ResetTimezoneCmd";
|
||||
|
@ -62,4 +62,7 @@ export const TimeAndDatePlugin = zeppelinGuildPlugin<TimeAndDatePluginType>()({
|
|||
beforeLoad(pluginData) {
|
||||
pluginData.state.memberTimezones = GuildMemberTimezones.getGuildInstance(pluginData.guild.id);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -23,4 +23,7 @@ export const UsernameSaverPlugin = zeppelinGuildPlugin<UsernameSaverPluginType>(
|
|||
state.usernameHistory = new UsernameHistory();
|
||||
state.updateQueue = new Queue();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -221,4 +221,7 @@ export const UtilityPlugin = zeppelinGuildPlugin<UtilityPluginType>()({
|
|||
beforeUnload(pluginData) {
|
||||
discardRegExpRunner(`guild-${pluginData.guild.id}`);
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -35,4 +35,7 @@ export const WelcomeMessagePlugin = zeppelinGuildPlugin<WelcomeMessagePluginType
|
|||
state.logs = new GuildLogs(guild.id);
|
||||
state.sentWelcomeMessages = new Set();
|
||||
},
|
||||
|
||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||
configParser: (o: any) => o,
|
||||
});
|
||||
|
|
|
@ -30,7 +30,8 @@ export interface ZeppelinGuildPluginBlueprint<TPluginData extends GuildPluginDat
|
|||
legacy?: boolean | string;
|
||||
};
|
||||
|
||||
configParser?: (
|
||||
// FIXME: need proper typings here
|
||||
configParser: (
|
||||
options: TPluginData["_pluginType"]["config"],
|
||||
strict?: boolean,
|
||||
) => Awaitable<PluginOptions<TPluginData["_pluginType"]>>;
|
||||
|
@ -67,7 +68,8 @@ export function zeppelinGuildPlugin(...args) {
|
|||
export interface ZeppelinGlobalPluginBlueprint<TPluginType extends BasePluginType = BasePluginType>
|
||||
extends GlobalPluginBlueprint<GlobalPluginData<TPluginType>> {
|
||||
configSchema: t.TypeC<any>;
|
||||
configParser?: (options: TPluginType["config"], strict?: boolean) => Awaitable<PluginOptions<TPluginType>>;
|
||||
// FIXME: need proper typings here
|
||||
configParser: (options: TPluginType["config"], strict?: boolean) => Awaitable<PluginOptions<TPluginType>>;
|
||||
}
|
||||
|
||||
export function zeppelinGlobalPlugin<TBlueprint extends ZeppelinGlobalPluginBlueprint>(
|
||||
|
|
Loading…
Add table
Reference in a new issue