Фикс clip

This commit is contained in:
JonnyBro 2022-01-08 04:14:04 +05:00
parent 38316f30ac
commit c6ac32561c
2 changed files with 16 additions and 11 deletions

View file

@ -46,7 +46,7 @@ class Rob extends Command {
const itsAWon = Math.floor(this.client.functions.randomNum(0, 100) < 25); const itsAWon = Math.floor(this.client.functions.randomNum(0, 100) < 25);
if (itsAWon) { if (itsAWon) {
const toWait = Date.now() + 6 * (60 * 60000); const toWait = Date.now() + 6 * (60 * 60000); // 6 hours
memberData.cooldowns.rob = toWait; memberData.cooldowns.rob = toWait;
memberData.markModified("cooldowns"); memberData.markModified("cooldowns");
await memberData.save(); await memberData.save();

View file

@ -1,5 +1,6 @@
const Command = require("../../base/Command.js"), const Command = require("../../base/Command.js"),
fs = require("fs"); fs = require("fs"),
{ joinVoiceChannel, createAudioResource, createAudioPlayer } = require("@discordjs/voice");
class Clip extends Command { class Clip extends Command {
constructor(client) { 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 }); if (!fs.existsSync(`./clips/${clip}.mp3`)) return message.error("music/clip:NO_FILE", { file: clip });
try { try {
const connection = await voice.join(); const connection = joinVoiceChannel({
await connection.voice.setSelfDeaf(true); channelId: voice.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator
});
connection.play(`./clips/${clip}.mp3`) const resource = createAudioResource(fs.createReadStream(`./clips/${clip}.mp3`));
.on("finish", () => { const player = createAudioPlayer()
voice.leave(); .on("error", error => {
}) connection.destroy();
.on("error", err => { console.error("Error:", error.message, "with track", error.resource.metadata.title);
voice.leave();
console.error(err);
}); });
player.play(resource);
connection.subscribe(player);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
}; };