scripts: move scripts to the project root directory
I believe, that these kind of scripts should reside there instead of src directory
This commit is contained in:
parent
b7f6a5fe91
commit
6a31473d22
4 changed files with 7 additions and 5 deletions
|
@ -1,42 +0,0 @@
|
|||
// https://discordjs.guide/creating-your-bot/command-deployment.html#guild-commands
|
||||
|
||||
import { REST, RESTGetAPIOAuth2CurrentApplicationResult, RESTPostAPIApplicationCommandsJSONBody, Routes } from "discord.js";
|
||||
import { config } from "../index";
|
||||
import requireDirectory from "require-directory";
|
||||
|
||||
import Command from "../command";
|
||||
|
||||
const post: RESTPostAPIApplicationCommandsJSONBody[] = [];
|
||||
|
||||
const guildId = process.argv.slice(2)[0];
|
||||
requireDirectory<{default: Command}, void>(module, "../commands", {
|
||||
visit: function (obj) {
|
||||
console.log(obj);
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
||||
post.push(new obj.default().toRESTPostApplicationCommands());
|
||||
},
|
||||
});
|
||||
|
||||
const rest = new REST().setToken(config.tokens.Discord);
|
||||
|
||||
(async () => {
|
||||
const me = await rest.get(Routes.oauth2CurrentApplication()) as RESTGetAPIOAuth2CurrentApplicationResult;
|
||||
if (guildId && guildId !== "") {
|
||||
console.log(`Started refreshing ${post.length} application guild (${guildId}) commands.`);
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(me.id, guildId),
|
||||
{ body: post },
|
||||
);
|
||||
} else {
|
||||
console.log(`Started refreshing ${post.length} application global commands.`);
|
||||
await rest.put(
|
||||
Routes.applicationCommands(me.id),
|
||||
{ body: post },
|
||||
);
|
||||
}
|
||||
console.log("Refreshed successfully");
|
||||
})().catch( e => {
|
||||
console.error(e);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue