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

Commit

Permalink
InstallUtils: ClearInteractions
Browse files Browse the repository at this point in the history
  • Loading branch information
RealEthanPlayzDev committed May 28, 2024
1 parent c5b1fc6 commit c701e16
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"compile": "tsc",
"start": "node dist",
"installUtils:fillMissingGuildData": "node ./dist/installUtils/fillMissingGuildData.js",
"installUtils:enableGuildFeature": "node ./dist/installUtils/enableGuildFeature.js"
"installUtils:enableGuildFeature": "node ./dist/installUtils/enableGuildFeature.js",
"installUtils:clearInteractions": "node ./dist/installUtils/clearInteractions.js"
},
"repository": {
"type": "git",
Expand Down
25 changes: 25 additions & 0 deletions src/installUtils/clearInteractions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import process from "node:process";
import MeteoriumClient from "../classes/client.js";
import { IntentsBitField } from "discord.js";

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

ciNS.warn("All interaction data will be cleared in 10 seconds!");
await new Promise((resolve) => setTimeout(resolve, 10000));
ciNS.info("Clearing global interaction data");
await client.application.commands.set([]);
client.config.ApplicationDeployGuildIds.forEach(async (guildId) => {
const guild = await client.guilds.fetch(guildId).catch(() => null);
if (!guild) return ciNS.error(`Cannot get guild ${guildId} for clearing interactions`);
ciNS.verbose(`Clearing interactions -> ${guildId}`);
await guild.commands.set([]);
});

await client.destroy();

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

0 comments on commit c701e16

Please sign in to comment.