Initial commit
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
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}`);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user