Include empty config in add_server bot control command
This commit is contained in:
parent
eab62acc6b
commit
4ae3ef477a
3 changed files with 11 additions and 0 deletions
|
@ -13,6 +13,7 @@ import { AllowServerCmd } from "./commands/AllowServerCmd";
|
||||||
import { DisallowServerCmd } from "./commands/DisallowServerCmd";
|
import { DisallowServerCmd } from "./commands/DisallowServerCmd";
|
||||||
import { AddDashboardUserCmd } from "./commands/AddDashboardUserCmd";
|
import { AddDashboardUserCmd } from "./commands/AddDashboardUserCmd";
|
||||||
import { RemoveDashboardUserCmd } from "./commands/RemoveDashboardUserCmd";
|
import { RemoveDashboardUserCmd } from "./commands/RemoveDashboardUserCmd";
|
||||||
|
import { Configs } from "../../data/Configs";
|
||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
config: {
|
config: {
|
||||||
|
@ -40,6 +41,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()("bo
|
||||||
onLoad(pluginData) {
|
onLoad(pluginData) {
|
||||||
pluginData.state.archives = new GuildArchives(0);
|
pluginData.state.archives = new GuildArchives(0);
|
||||||
pluginData.state.allowedGuilds = new AllowedGuilds();
|
pluginData.state.allowedGuilds = new AllowedGuilds();
|
||||||
|
pluginData.state.configs = new Configs();
|
||||||
|
|
||||||
if (getActiveReload()) {
|
if (getActiveReload()) {
|
||||||
const [guildId, channelId] = getActiveReload();
|
const [guildId, channelId] = getActiveReload();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
|
import { isSnowflake } from "../../../utils";
|
||||||
|
|
||||||
export const AllowServerCmd = botControlCmd({
|
export const AllowServerCmd = botControlCmd({
|
||||||
trigger: ["allow_server", "allowserver", "add_server", "addserver"],
|
trigger: ["allow_server", "allowserver", "add_server", "addserver"],
|
||||||
|
@ -20,7 +21,13 @@ export const AllowServerCmd = botControlCmd({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isSnowflake(args.guildId)) {
|
||||||
|
sendErrorMessage(pluginData, msg.channel, "Invalid server ID!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await pluginData.state.allowedGuilds.add(args.guildId);
|
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!");
|
sendSuccessMessage(pluginData, msg.channel, "Server is now allowed to use Zeppelin!");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { BasePluginType, globalCommand, globalEventListener } from "knub";
|
||||||
import { GuildArchives } from "../../data/GuildArchives";
|
import { GuildArchives } from "../../data/GuildArchives";
|
||||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||||
|
import { Configs } from "../../data/Configs";
|
||||||
|
|
||||||
export const ConfigSchema = t.type({
|
export const ConfigSchema = t.type({
|
||||||
can_use: t.boolean,
|
can_use: t.boolean,
|
||||||
|
@ -17,6 +18,7 @@ export interface BotControlPluginType extends BasePluginType {
|
||||||
archives: GuildArchives;
|
archives: GuildArchives;
|
||||||
allowedGuilds: AllowedGuilds;
|
allowedGuilds: AllowedGuilds;
|
||||||
apiPermissionAssignments: ApiPermissionAssignments;
|
apiPermissionAssignments: ApiPermissionAssignments;
|
||||||
|
configs: Configs;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue