This repository has been archived on 2026-01-13. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Lunaris/utils/registerCommands.js
2023-06-23 10:36:24 +02:00

55 lines
1.7 KiB
JavaScript

const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
async function registerCommands(clientId, token) {
const commands = [
new SlashCommandBuilder()
.setName('play')
.setDescription('Plays songs!')
.addStringOption(option =>
option.setName('input')
.setDescription('Play song from YouTube, Spotify, SoundCloud, etc.')
.setRequired(true)
),
new SlashCommandBuilder()
.setName('queue')
.setDescription('Adds a song to the queue!')
.addStringOption(option =>
option.setName('song')
.setDescription('Add song from YouTube, Spotify, SoundCloud, etc. to the queue')
.setRequired(true)
),
new SlashCommandBuilder()
.setName('pause')
.setDescription('Pauses the current song!'),
new SlashCommandBuilder()
.setName('resume')
.setDescription('Resumes the current song!'),
new SlashCommandBuilder()
.setName('loop')
.setDescription('Loops the current song!')
.addBooleanOption(option =>
option.setName('looping')
.setDescription('Enable or disable looping')
.setRequired(true)
)
];
const rest = new REST({ version: '9' }).setToken(token);
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
}
module.exports.registerCommands = registerCommands;