50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
const { REST, Routes, SlashCommandBuilder } = require('discord.js');
|
|
const path = require('path');
|
|
require('dotenv').config({ path: path.join(__dirname, '.env') });
|
|
|
|
const commands = [
|
|
new SlashCommandBuilder()
|
|
.setName('join')
|
|
.setDescription('Bot join ke voice channel kamu'),
|
|
new SlashCommandBuilder()
|
|
.setName('testsahur')
|
|
.setDescription('Putar suara sahur.mp3 untuk mengetes'),
|
|
new SlashCommandBuilder()
|
|
.setName('play')
|
|
.setDescription('Putar musik dari YouTube, SoundCloud, atau Spotify')
|
|
.addStringOption(option =>
|
|
option.setName('query')
|
|
.setDescription('Link atau judul lagu')
|
|
.setRequired(true)),
|
|
new SlashCommandBuilder()
|
|
.setName('pause')
|
|
.setDescription('Pause musik yang sedang diputar'),
|
|
new SlashCommandBuilder()
|
|
.setName('resume')
|
|
.setDescription('Lanjutkan musik yang dipause'),
|
|
new SlashCommandBuilder()
|
|
.setName('skip')
|
|
.setDescription('Lewati lagu saat ini'),
|
|
new SlashCommandBuilder()
|
|
.setName('stop')
|
|
.setDescription('Berhentikan musik dan hapus antrean'),
|
|
].map(command => command.toJSON());
|
|
|
|
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);
|
|
|
|
(async () => {
|
|
try {
|
|
console.log('Sedang mendaftarkan slash commands...');
|
|
|
|
// Register globally
|
|
await rest.put(
|
|
Routes.applicationCommands(process.env.CLIENT_ID),
|
|
{ body: commands },
|
|
);
|
|
|
|
console.log('Berhasil mendaftarkan slash commands!');
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
})();
|