Include empty config in add_server bot control command

This commit is contained in:
Dragory 2020-10-10 15:29:23 +03:00
parent eab62acc6b
commit 4ae3ef477a
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
3 changed files with 11 additions and 0 deletions

View file

@ -13,6 +13,7 @@ import { AllowServerCmd } from "./commands/AllowServerCmd";
import { DisallowServerCmd } from "./commands/DisallowServerCmd";
import { AddDashboardUserCmd } from "./commands/AddDashboardUserCmd";
import { RemoveDashboardUserCmd } from "./commands/RemoveDashboardUserCmd";
import { Configs } from "../../data/Configs";
const defaultOptions = {
config: {
@ -40,6 +41,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()("bo
onLoad(pluginData) {
pluginData.state.archives = new GuildArchives(0);
pluginData.state.allowedGuilds = new AllowedGuilds();
pluginData.state.configs = new Configs();
if (getActiveReload()) {
const [guildId, channelId] = getActiveReload();

View file

@ -1,6 +1,7 @@
import { botControlCmd } from "../types";
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { isSnowflake } from "../../../utils";
export const AllowServerCmd = botControlCmd({
trigger: ["allow_server", "allowserver", "add_server", "addserver"],
@ -20,7 +21,13 @@ export const AllowServerCmd = botControlCmd({
return;
}
if (!isSnowflake(args.guildId)) {
sendErrorMessage(pluginData, msg.channel, "Invalid server ID!");
return;
}
await pluginData.state.allowedGuilds.add(args.guildId);
await pluginData.state.configs.saveNewRevision(`guild-${args.guildId}`, "plugins: {}", msg.author.id);
sendSuccessMessage(pluginData, msg.channel, "Server is now allowed to use Zeppelin!");
},
});

View file

@ -4,6 +4,7 @@ import { BasePluginType, globalCommand, globalEventListener } from "knub";
import { GuildArchives } from "../../data/GuildArchives";
import { AllowedGuilds } from "../../data/AllowedGuilds";
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
import { Configs } from "../../data/Configs";
export const ConfigSchema = t.type({
can_use: t.boolean,
@ -17,6 +18,7 @@ export interface BotControlPluginType extends BasePluginType {
archives: GuildArchives;
allowedGuilds: AllowedGuilds;
apiPermissionAssignments: ApiPermissionAssignments;
configs: Configs;
};
}