Fix error when starring a post for starboard
This commit is contained in:
parent
dc25b67672
commit
49559c14fd
2 changed files with 11 additions and 20 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Add table
Reference in a new issue