diff --git a/commands/Economy/rob.js b/commands/Economy/rob.js index 0822be45..6a4b4017 100644 --- a/commands/Economy/rob.js +++ b/commands/Economy/rob.js @@ -46,7 +46,7 @@ class Rob extends Command { const itsAWon = Math.floor(this.client.functions.randomNum(0, 100) < 25); if (itsAWon) { - const toWait = Date.now() + 6 * (60 * 60000); + const toWait = Date.now() + 6 * (60 * 60000); // 6 hours memberData.cooldowns.rob = toWait; memberData.markModified("cooldowns"); await memberData.save(); diff --git a/commands/Music/clip.js b/commands/Music/clip.js index 10713edc..b951c873 100644 --- a/commands/Music/clip.js +++ b/commands/Music/clip.js @@ -1,5 +1,6 @@ const Command = require("../../base/Command.js"), - fs = require("fs"); + fs = require("fs"), + { joinVoiceChannel, createAudioResource, createAudioPlayer } = require("@discordjs/voice"); class Clip extends Command { constructor(client) { @@ -29,17 +30,21 @@ class Clip extends Command { if (!fs.existsSync(`./clips/${clip}.mp3`)) return message.error("music/clip:NO_FILE", { file: clip }); try { - const connection = await voice.join(); - await connection.voice.setSelfDeaf(true); + const connection = joinVoiceChannel({ + channelId: voice.id, + guildId: message.guild.id, + adapterCreator: message.guild.voiceAdapterCreator + }); - connection.play(`./clips/${clip}.mp3`) - .on("finish", () => { - voice.leave(); - }) - .on("error", err => { - voice.leave(); - console.error(err); + const resource = createAudioResource(fs.createReadStream(`./clips/${clip}.mp3`)); + const player = createAudioPlayer() + .on("error", error => { + connection.destroy(); + console.error("Error:", error.message, "with track", error.resource.metadata.title); }); + + player.play(resource); + connection.subscribe(player); } catch (error) { console.error(error); };