diff --git a/package.json b/package.json index 4e75f2b..a52887c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/installUtils/clearInteractions.ts b/src/installUtils/clearInteractions.ts new file mode 100644 index 0000000..37a3034 --- /dev/null +++ b/src/installUtils/clearInteractions.ts @@ -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);