From b9391bfac1aefc02bb51fb532c95a8a3e1c9f818 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Tue, 5 Oct 2021 19:37:20 +0200 Subject: :sparkles: added autoJoin guild to config --- api/src/util/Instance.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 api/src/util/Instance.ts (limited to 'api/src/util') diff --git a/api/src/util/Instance.ts b/api/src/util/Instance.ts new file mode 100644 index 00000000..a7b3205a --- /dev/null +++ b/api/src/util/Instance.ts @@ -0,0 +1,18 @@ +import { Config, Guild } from "@fosscord/util"; + +export async function initInstance() { + // TODO: clean up database and delete tombstone data + // TODO: set first user as instance administrator/or generate one if none exists and output it in the terminal + + // create default guild and add it to auto join + // TODO: check if any current user is not part of autoJoinGuilds + const { autoJoin } = Config.get().guild; + + if (autoJoin.enabled && autoJoin.guilds?.length) { + let guild = await Guild.findOne({}); + if (!guild) guild = await Guild.createGuild({}); + + // @ts-ignore + await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } }); + } +} -- cgit 1.5.1