diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2022-03-27 23:41:04 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2022-03-27 23:41:04 -0400 |
| commit | e438a195c730bc1609917059bd434afdfa1354f7 (patch) | |
| tree | 4064348fd15262a46256b254e5a4ba4de10a0a4e /bot.js | |
| parent | ae48ba2014bca4a10adf8cf8b6fb0d9e6d4ff401 (diff) | |
| download | DLAP-e438a195c730bc1609917059bd434afdfa1354f7.tar.gz DLAP-e438a195c730bc1609917059bd434afdfa1354f7.tar.bz2 DLAP-e438a195c730bc1609917059bd434afdfa1354f7.zip | |
Half converted the codebase EMS + added ideas
Diffstat (limited to 'bot.js')
| -rw-r--r-- | bot.js | 39 |
1 files changed, 24 insertions, 15 deletions
@@ -1,6 +1,6 @@ /************************************************************************** * - * DLMP3 Bot: A Discord bot that plays local mp3 audio tracks. + * DLMP3 Bot: A Discord bot that plays local MP3 audio tracks. * (C) Copyright 2022 * Programmed by Andrew Lee * @@ -18,25 +18,31 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * ***************************************************************************/ -const { Client, MessageEmbed, Collection, version } = require('discord.js'); -const fs = require('fs'); -const { getVoiceConnection } = require('@discordjs/voice'); -const bot = new Client({intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_VOICE_STATES']}); -const config = require('./config.json'); -const AudioBackend = require('./AudioBackend'); -let audio; +import { Client, MessageEmbed, Collection, version } from "discord.js" +import { voiceInit } from "./AudioBackend.js" +import fs from "fs" +import config from './config.json' assert {type: 'json'} + +export const bot = new Client({intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_VOICE_STATES']}); let fileData; let txtFile = true; bot.login(config.token); +/** + * Project Ideas: + * Play directly the MP3 file + * New queue system + * List MP3 files + */ + // Slash Command Handler bot.commands = new Collection(); const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); for (const file of commandFiles) { - const command = require(`./commands/${file}`); + const { default: command } = await import(`./commands/${file}`); bot.commands.set(command.data.name, command); } @@ -73,9 +79,7 @@ bot.once('ready', () => { if (!statusChannel) return console.error('The status channel does not exist! Skipping.'); statusChannel.send({ embeds: [readyEmbed]}); - //voiceInit(); - - AudioBackend(bot, config); + voiceInit(bot); }); @@ -87,13 +91,18 @@ bot.on('interactionCreate', async interaction => { if (!command) return; try { - await command.execute(interaction, bot, player, audio); + await command.execute(interaction, bot); } catch (error) { console.error(error); - await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); + if (error == null) { + await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); + } else { + await interaction.reply({ content: `There was an error while executing this command!\nShare this to the bot owner!\n\nDetails:\`\`\`${error}\`\`\``, ephemeral: true }); + } } }); +/* bot.on('messageCreate', async msg => { if (msg.author.bot) return; if (!msg.guild) return; @@ -198,4 +207,4 @@ bot.on('messageCreate', async msg => { process.exit(0); } -}); +});*/ |
