chore: Adding delete All Commands script
This commit is contained in:
parent
d4109752e8
commit
8e856b4f5f
3 changed files with 50 additions and 1 deletions
|
@ -30,6 +30,7 @@
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-prettier": "^5.2.3",
|
"eslint-plugin-prettier": "^5.2.3",
|
||||||
"globals": "^15.15.0",
|
"globals": "^15.15.0",
|
||||||
|
"minimist": "^1.2.8",
|
||||||
"nodemon": "^3.1.9",
|
"nodemon": "^3.1.9",
|
||||||
"prettier": "^3.5.2",
|
"prettier": "^3.5.2",
|
||||||
"prisma": "^5.22.0",
|
"prisma": "^5.22.0",
|
||||||
|
@ -41,7 +42,8 @@
|
||||||
"start": "cross-env NODE_ENV=production node dist/src",
|
"start": "cross-env NODE_ENV=production node dist/src",
|
||||||
"db:pull": "prisma db pull",
|
"db:pull": "prisma db pull",
|
||||||
"db:push": "prisma db push",
|
"db:push": "prisma db push",
|
||||||
"db:generate": "prisma generate"
|
"db:generate": "prisma generate",
|
||||||
|
"deleteAllCommands": "node scripts/deleteAllCommands"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@types/ws": "^8.5.11",
|
"@types/ws": "^8.5.11",
|
||||||
|
|
|
@ -85,6 +85,9 @@ importers:
|
||||||
globals:
|
globals:
|
||||||
specifier: ^15.15.0
|
specifier: ^15.15.0
|
||||||
version: 15.15.0
|
version: 15.15.0
|
||||||
|
minimist:
|
||||||
|
specifier: ^1.2.8
|
||||||
|
version: 1.2.8
|
||||||
nodemon:
|
nodemon:
|
||||||
specifier: ^3.1.9
|
specifier: ^3.1.9
|
||||||
version: 3.1.9
|
version: 3.1.9
|
||||||
|
@ -672,6 +675,9 @@ packages:
|
||||||
resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}
|
resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}
|
||||||
engines: {node: '>=16 || 14 >=14.17'}
|
engines: {node: '>=16 || 14 >=14.17'}
|
||||||
|
|
||||||
|
minimist@1.2.8:
|
||||||
|
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
||||||
|
|
||||||
ms@2.1.3:
|
ms@2.1.3:
|
||||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||||
|
|
||||||
|
@ -1502,6 +1508,8 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion: 2.0.1
|
brace-expansion: 2.0.1
|
||||||
|
|
||||||
|
minimist@1.2.8: {}
|
||||||
|
|
||||||
ms@2.1.3: {}
|
ms@2.1.3: {}
|
||||||
|
|
||||||
natural-compare@1.4.0: {}
|
natural-compare@1.4.0: {}
|
||||||
|
|
39
scripts/deleteAllCommands.js
Normal file
39
scripts/deleteAllCommands.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||||
|
const { REST, Routes } = require('discord.js')
|
||||||
|
const readline = require('readline/promises')
|
||||||
|
require('dotenv/config')
|
||||||
|
|
||||||
|
const argv = require('minimist')(process.argv.slice(2), {
|
||||||
|
string: ['id'],
|
||||||
|
})
|
||||||
|
|
||||||
|
const rl = readline.createInterface({
|
||||||
|
input: process.stdin,
|
||||||
|
output: process.stdout,
|
||||||
|
})
|
||||||
|
|
||||||
|
;(async () => {
|
||||||
|
if (!argv.y) {
|
||||||
|
const answer = await rl.question(
|
||||||
|
'Do you want to delete all commands? [y/N]: ',
|
||||||
|
)
|
||||||
|
|
||||||
|
if (answer.toLowerCase() !== 'y') {
|
||||||
|
rl.close()
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!process.env.BOT_TOKEN)
|
||||||
|
throw new Error('You need a BOT_TOKEN environment.')
|
||||||
|
|
||||||
|
if (!argv.id) throw new Error('You need a --id flag value.')
|
||||||
|
|
||||||
|
const rest = new REST().setToken(process.env.BOT_TOKEN)
|
||||||
|
|
||||||
|
rest.put(Routes.applicationCommands(argv.id), {
|
||||||
|
body: {},
|
||||||
|
})
|
||||||
|
|
||||||
|
rl.close()
|
||||||
|
})()
|
Loading…
Reference in a new issue