mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 13:14: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);
|
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();
|
||||||
|
|
|
@ -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,
|
||||||
connection.play(`./clips/${clip}.mp3`)
|
adapterCreator: message.guild.voiceAdapterCreator
|
||||||
.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) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue