3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Fix error when starring a post for starboard

This commit is contained in:
Dragory 2020-07-29 20:08:41 +03:00
parent dc25b67672
commit 49559c14fd
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 11 additions and 20 deletions

View file

@ -1,5 +1,5 @@
import { PluginOptions } from "knub";
import { ConfigSchema, StarboardPluginType } from "./types";
import { ConfigSchema, defaultStarboardOpts, StarboardPluginType } from "./types";
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { trimPluginDescription } from "src/utils";
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
@ -89,6 +89,16 @@ export const StarboardPlugin = zeppelinPlugin<StarboardPluginType>()("starboard"
`),
},
configPreprocessor(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]);
}
}
return options;
},
// prettier-ignore
commands: [
MigratePinsCmd,

View file

@ -1,19 +0,0 @@
import { TStarboardOpts, StarboardPluginType, defaultStarboardOpts } from "../types";
import { PluginData } from "knub";
export function getStarboardOptsForStarboardChannel(
pluginData: PluginData<StarboardPluginType>,
starboardChannel,
): TStarboardOpts[] {
const config = pluginData.config.getForChannel(starboardChannel);
const configs = Object.values(config.boards).filter(opts => opts.channel_id === starboardChannel.id);
configs.forEach(cfg => {
if (cfg.enabled == null) cfg.enabled = defaultStarboardOpts.enabled;
if (cfg.star_emoji == null) cfg.star_emoji = defaultStarboardOpts.star_emoji;
if (cfg.stars_required == null) cfg.stars_required = defaultStarboardOpts.stars_required;
if (cfg.copy_full_embed == null) cfg.copy_full_embed = false;
});
return configs;
}