mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
Фикс clip
This commit is contained in:
parent
38316f30ac
commit
c6ac32561c
2 changed files with 16 additions and 11 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue