aboutsummaryrefslogtreecommitdiff
path: root/bot.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2022-03-26 13:43:03 -0400
committerAndrew Lee <alee14498@protonmail.com>2022-03-26 13:43:03 -0400
commitd55e74693da3c7b2705d67aa1880baaa0dcd1790 (patch)
tree2588b36a5510adf40295ad1389964e194cb9a742 /bot.js
parent9e2ba5ceb9e7d1e8a4305be36205dde3cfb5b0b9 (diff)
downloadDLAP-d55e74693da3c7b2705d67aa1880baaa0dcd1790.tar.gz
DLAP-d55e74693da3c7b2705d67aa1880baaa0dcd1790.tar.bz2
DLAP-d55e74693da3c7b2705d67aa1880baaa0dcd1790.zip
New interaction handler; Merged git and about
Diffstat (limited to 'bot.js')
-rw-r--r--bot.js30
1 files changed, 26 insertions, 4 deletions
diff --git a/bot.js b/bot.js
index 32afb74..a4b2796 100644
--- a/bot.js
+++ b/bot.js
@@ -44,7 +44,7 @@ function voiceInit() {
});
connection.on(VoiceConnectionStatus.Destroyed, () => {
- console.log('Stopping music...');
+ console.log('Destroying beats...');
});
player.on('idle', () => {
@@ -58,7 +58,6 @@ function voiceInit() {
}
function playAudio() {
-
let files = fs.readdirSync(join(__dirname,'music'));
while (true) {
@@ -91,7 +90,15 @@ function playAudio() {
}
-bot.on('ready', () => {
+bot.commands = new Discord.Collection();
+const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
+
+for (const file of commandFiles) {
+ const command = require(`./commands/${file}`);
+ bot.commands.set(command.data.name, command);
+}
+
+bot.once('ready', () => {
console.log('Bot is ready!');
console.log(`Logged in as ${bot.user.tag}!`);
console.log(`Running on Discord.JS ${Discord.version}`)
@@ -104,7 +111,7 @@ bot.on('ready', () => {
bot.user.setPresence({
activities: [{
- name: `Music | ${config.prefix}help`,
+ name: 'some beats',
type: 'LISTENING'
}],
status: 'online',
@@ -127,6 +134,21 @@ bot.on('ready', () => {
});
+bot.on('interactionCreate', async interaction => {
+ if (!interaction.isCommand()) return;
+
+ const command = bot.commands.get(interaction.commandName);
+
+ if (!command) return;
+
+ try {
+ await command.execute(interaction, bot);
+ } catch (error) {
+ console.error(error);
+ await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
+ }
+});
+
bot.on('messageCreate', async msg => {
if (msg.author.bot) return;
if (!msg.guild) return;