mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
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 { 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();
|
||||
|
|
|
@ -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!");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue