aboutsummaryrefslogtreecommitdiff
path: root/bot.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2022-03-26 17:53:07 -0400
committerAndrew Lee <alee14498@protonmail.com>2022-03-26 17:53:07 -0400
commit7e814d36e97bc3a7a17dcde4b5b373e647c6f6d0 (patch)
treeedc1db8fb415d3e001443c73e3b84e327c96e9f9 /bot.js
parentd55e74693da3c7b2705d67aa1880baaa0dcd1790 (diff)
downloadDLAP-7e814d36e97bc3a7a17dcde4b5b373e647c6f6d0.tar.gz
DLAP-7e814d36e97bc3a7a17dcde4b5b373e647c6f6d0.tar.bz2
DLAP-7e814d36e97bc3a7a17dcde4b5b373e647c6f6d0.zip
Some tweaks
Diffstat (limited to 'bot.js')
-rw-r--r--bot.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/bot.js b/bot.js
index a4b2796..9aaeed7 100644
--- a/bot.js
+++ b/bot.js
@@ -18,11 +18,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
***************************************************************************/
-const Discord = require('discord.js');
+const { Client, MessageEmbed, Collection, version } = require('discord.js');
const fs = require('fs');
const { join } = require('node:path');
const { createAudioPlayer, createAudioResource, joinVoiceChannel, VoiceConnectionStatus, getVoiceConnection } = require('@discordjs/voice');
-const bot = new Discord.Client({intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_VOICE_STATES']});
+const bot = new Client({intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_VOICE_STATES']});
const config = require('./config.json');
const player = createAudioPlayer();
let audio;
@@ -80,7 +80,7 @@ function playAudio() {
console.log(err);
});
}
- const statusEmbed = new Discord.MessageEmbed()
+ const statusEmbed = new MessageEmbed()
.addField('Now Playing', `${audio}`)
.setColor('#0066ff')
@@ -90,7 +90,9 @@ function playAudio() {
}
-bot.commands = new Discord.Collection();
+// Slash Command Handler
+
+bot.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
@@ -101,14 +103,13 @@ for (const file of commandFiles) {
bot.once('ready', () => {
console.log('Bot is ready!');
console.log(`Logged in as ${bot.user.tag}!`);
- console.log(`Running on Discord.JS ${Discord.version}`)
+ console.log(`Running on Discord.JS ${version}`)
console.log(`Prefix: ${config.prefix}`);
console.log(`Owner ID: ${config.botOwner}`);
console.log(`Voice Channel: ${config.voiceChannel}`);
console.log(`Status Channel: ${config.statusChannel}\n`);
// Set bots' presence
-
bot.user.setPresence({
activities: [{
name: 'some beats',
@@ -121,7 +122,7 @@ bot.once('ready', () => {
console.log(`Updated bot presence to "${activity.name}"`);
// Send bots' status to channel
- const readyEmbed = new Discord.MessageEmbed()
+ const readyEmbed = new MessageEmbed()
.setAuthor({name:bot.user.username, iconURL:bot.user.avatarURL()})
.setDescription('Starting bot...')
.setColor('#0066ff')
@@ -142,7 +143,7 @@ bot.on('interactionCreate', async interaction => {
if (!command) return;
try {
- await command.execute(interaction, bot);
+ await command.execute(interaction, bot, player, audio);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
@@ -159,7 +160,7 @@ bot.on('messageCreate', async msg => {
// Public allowed commands
if (command === 'help') {
- const helpEmbed = new Discord.MessageEmbed()
+ const helpEmbed = new MessageEmbed()
.setAuthor({name:`${bot.user.username} Help`, iconURL:bot.user.avatarURL()})
.setDescription(`Currently playing \`${audio}\`.`)
.addField('Public Commands', `${config.prefix}help\n${config.prefix}ping\n${config.prefix}git\n${config.prefix}playing\n${config.prefix}about\n`, true)
@@ -238,7 +239,7 @@ bot.on('messageCreate', async msg => {
console.log(err);
});
}
- const statusEmbed = new Discord.MessageEmbed()
+ const statusEmbed = new MessageEmbed()
.setAuthor({name:bot.user.username, iconURL:bot.user.avatarURL()})
.setDescription(`That\'s all folks! Powering down ${bot.user.username}...`)
.setColor('#0066ff')