Files
2025-05-13 20:05:28 +02:00

95 lines
2.7 KiB
JavaScript

const config = require("./config.json");
const {REST, Routes, ApplicationCommandOptionType } = require("discord.js");
var guildid = "1288521679206748260";
var clientId = "1288554103873736785";
const rest = new REST({version: '10'}).setToken(config.token);
const commands = [
{
name: 'trafalgar',
description: 'Sende eine Nachricht als "Trafalgar Law"',
options: [
{
name: 'channel',
description: 'Der Channel in den die Nachricht geschickt werden soll',
type: ApplicationCommandOptionType.Channel,
required: true,
},
{
name: 'message',
description: 'Die Nachricht die der Bot schreiben soll',
type: ApplicationCommandOptionType.String,
required: true,
},
],
},
{
name: 'siskelshandlanger',
description: 'Sende eine Nachricht als "Siskels Handlanger"',
options: [
{
name: 'channel',
description: 'Der Channel in den die Nachricht geschickt werden soll',
type: ApplicationCommandOptionType.Channel,
required: true,
},
{
name: 'message',
description: 'Die Nachricht die der Bot schreiben soll',
type: ApplicationCommandOptionType.String,
required: true,
},
],
},
];
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
(async () => {
temp = await rest.get("/applications/" + clientId + "/commands");
await temp.forEach((item) => {
rest.delete(Routes.applicationCommand(clientId, item.id))
.then(() => console.log('Successfully deleted guild command: ' + item.name))
.catch(console.error);
});
await sleep(1000);
console.log("\nSuccessfully Deleted all Command -> Now Adding new and Readding all Commands\n");
await sleep(1000);
try {
let listOfAllCommands = "";
commands.forEach((item) => {
if (listOfAllCommands != "") {
listOfAllCommands += ", ";
}
listOfAllCommands += "/" + item.name;
});
if (listOfAllCommands == "") {
listOfAllCommands = "Empty List";
}
console.log("Registering Commands: " + listOfAllCommands);
await rest.put(
Routes.applicationCommands(clientId),
{
body: commands
}
);
console.log("Registered");
} catch (error) {
console.log(`error: ${error}`);
}
})();