mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
feat: add DEFAULT_ALLOWED_SERVERS .env value
This commit is contained in:
parent
f7fede47bd
commit
4a5e8ded75
4 changed files with 20 additions and 1 deletions
|
@ -3,6 +3,8 @@ import * as t from "io-ts";
|
|||
import { BasePluginType, GlobalPluginData, typedGlobalEventListener } from "knub";
|
||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { env } from "../../env";
|
||||
import { Configs } from "../../data/Configs";
|
||||
|
||||
interface GuildAccessMonitorPluginType extends BasePluginType {
|
||||
config: {};
|
||||
|
@ -35,8 +37,19 @@ export const GuildAccessMonitorPlugin = zeppelinGlobalPlugin<GuildAccessMonitorP
|
|||
}),
|
||||
],
|
||||
|
||||
beforeLoad(pluginData) {
|
||||
async beforeLoad(pluginData) {
|
||||
pluginData.state.allowedGuilds = new AllowedGuilds();
|
||||
|
||||
const defaultAllowedServers = env.DEFAULT_ALLOWED_SERVERS || [];
|
||||
const configs = new Configs();
|
||||
for (const serverId of defaultAllowedServers) {
|
||||
if (! await pluginData.state.allowedGuilds.isAllowed(serverId)) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log(`Adding allowed-by-default server ${serverId} to the allowed servers`);
|
||||
await pluginData.state.allowedGuilds.add(serverId);
|
||||
await configs.saveNewRevision(`guild-${serverId}`, "plugins: {}", 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
afterLoad(pluginData) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue