Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
InstallUtils: EnableGuildFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
RadiatedExodus committed Mar 10, 2024
1 parent 24afc70 commit 7cdbab3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scripts": {
"compile": "tsc",
"start": "node dist",
"installUtils:fillMissingGuildData": "node ./dist/installUtils/fillMissingGuildData.js"
"installUtils:fillMissingGuildData": "node ./dist/installUtils/fillMissingGuildData.js",
"installUtils:enableGuildFeature": "node ./dist/installUtils/enableGuildFeature.js"
},
"repository": {
"type": "git",
Expand Down
20 changes: 20 additions & 0 deletions src/installUtils/enableGuildFeature.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import process from "node:process";
import MeteoriumClient from "../classes/client.js";
import { IntentsBitField } from "discord.js";
import { GuildFeatures } from "@prisma/client";

const client = new MeteoriumClient({
intents: [IntentsBitField.Flags.Guilds],
});
const egfNS = client.logging.registerNamespace("InstallUtils").registerNamespace("EnableGuildFeature");
await client.login();

const guildId = process.env.METEORIUM_EGF_GUILDID;
const feature = GuildFeatures[process.env.METEORIUM_EGF_FEATURENAME as "Moderation"];
if (guildId && feature) await client.guildFeatures.enableFeature(guildId, feature);
else egfNS.error(`Configuration is incorrect, detected:\nGuild id: ${guildId}\nFeature: ${feature}`);

await client.destroy();

egfNS.info("Done");
process.exit(0);

0 comments on commit 7cdbab3

Please sign in to comment.