Permission system on certain commands

This commit is contained in:
Andrew Lee 2022-03-29 00:03:42 -04:00
parent 08aae8cd9e
commit 18f0b9d60c
Signed by: andrew
GPG key ID: 4DCE67C47836D125
7 changed files with 11 additions and 9 deletions

View file

@ -43,7 +43,7 @@ export function voiceInit(bot) {
});
connection.on(VoiceConnectionStatus.Ready, () => {
console.log('Ready to blast music!');
console.log('Ready to blast some beats!');
});
connection.on(VoiceConnectionStatus.Destroyed, () => {
@ -51,7 +51,7 @@ export function voiceInit(bot) {
});
player.on('idle', () => {
console.log("Music has finished playing, shuffling music...")
console.log("Music has finished playing, shuffling the beats...")
playAudio(bot);
})

2
bot.js
View file

@ -52,8 +52,6 @@ bot.once('ready', () => {
console.log(`Voice Channel: ${config.voiceChannel}`);
console.log(`Status Channel: ${config.statusChannel}`);
console.log(`Owner ID: ${config.botOwner}`);
console.log(`Guild ID: ${config.guildID}`);
console.log(`Client ID: ${config.clientID}\n`);
// Set bots' presence
bot.user.setPresence({

View file

@ -30,8 +30,9 @@ export default {
.setName('control')
.setDescription('Controlling the music'),
async execute(interaction, bot) {
if (![config.botOwner].includes(interaction.user.id)) return await interaction.reply({ content: "You do not have permissions to execute this command.", ephemeral: true });
const controlEmbed = new MessageEmbed()
.setAuthor({name:`${bot.user.username} Control Panel`, iconURL:bot.user.avatarURL()})
.setAuthor({name: `${bot.user.username} Control Panel`, iconURL: bot.user.avatarURL()})
.addField('State', 'Playing')
.addField('Currently Playing', audio)
//.addField('Next Music', '(a possible feature when queue system is implemented?)')

View file

@ -21,12 +21,14 @@
import { SlashCommandBuilder } from '@discordjs/builders'
import { voiceInit } from "../AudioBackend.js";
import config from '../config.json' assert {type: 'json'}
export default {
data: new SlashCommandBuilder()
.setName('join')
.setDescription('Joins voice chat.'),
async execute(interaction, bot) {
if (![config.botOwner].includes(interaction.user.id)) return await interaction.reply({ content: "You do not have permissions to execute this command.", ephemeral: true });
await interaction.reply('Joining voice channel')
voiceInit(bot);
},

View file

@ -29,9 +29,9 @@ export default {
.setName('list')
.setDescription('Lists the available audio tracks'),
async execute(interaction) {
/*
interaction.reply('Listing the available audio tracks...');
fs.readdirSync(musicFolder).forEach(file => {
return interaction.reply('Listing the available audio tracks...\n' + file);
});*/
console.log(file);
});
},
};

View file

@ -29,6 +29,7 @@ export default {
.setName('stop')
.setDescription('Powers off the bot'),
async execute(interaction, bot) {
if (![config.botOwner].includes(interaction.user.id)) return await interaction.reply({ content: "You do not have permissions to execute this command.", ephemeral: true });
await interaction.reply('Powering off...')
const statusEmbed = new MessageEmbed()

View file

@ -11,7 +11,7 @@ for (const file of commandFiles) {
commands.push(command.data.toJSON());
}
const rest = new REST({ version: '9' }).setToken(config.token);
const rest = new REST({ version: '10' }).setToken(config.token);
rest.put(Routes.applicationGuildCommands(config.clientID, config.guildID), { body: commands })
.then(() => console.log('Successfully registered application commands.'))