Фикс clip
This commit is contained in:
JonnyBro 2022-02-09 15:59:05 +05:00
parent 476ed2a8dd
commit 0454afd2bd
3 changed files with 10 additions and 6 deletions

View file

@ -1,6 +1,6 @@
const Command = require("../../base/Command"), const Command = require("../../base/Command"),
fs = require("fs"), fs = require("fs"),
{ joinVoiceChannel, createAudioResource, createAudioPlayer, getVoiceConnection } = require("@discordjs/voice"); { joinVoiceChannel, createAudioResource, createAudioPlayer, getVoiceConnection, AudioPlayerStatus } = require("@discordjs/voice");
class Clip extends Command { class Clip extends Command {
constructor(client) { constructor(client) {
@ -38,17 +38,17 @@ class Clip extends Command {
const resource = createAudioResource(fs.createReadStream(`./clips/${clip}.mp3`)); const resource = createAudioResource(fs.createReadStream(`./clips/${clip}.mp3`));
const player = createAudioPlayer() const player = createAudioPlayer()
.on("error", error => { .on("error", err => {
connection.destroy(); connection.destroy();
console.error("Error:", error.message, "with track", error.resource.metadata.title); console.error(err.message);
}); });
player.play(resource); player.play(resource);
connection.subscribe(player); connection.subscribe(player);
setTimeout(() => { player.on(AudioPlayerStatus.Idle, () => {
connection.destroy(); connection.destroy();
}, 60 * 1000); });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }

View file

@ -1,3 +1,7 @@
### JaBa v3.3.8
* Исправления
* Команда *clip* теперь работает нормально.
### JaBa v3.3.7 ### JaBa v3.3.7
* Добавлено * Добавлено
* Локализация необходимых прав в ошибке. * Локализация необходимых прав в ошибке.

View file

@ -1,6 +1,6 @@
{ {
"name": "jaba", "name": "jaba",
"version": "3.3.7", "version": "3.3.8",
"description": "A very complete Discord bot (more than 100 commands) that uses the Discord.js", "description": "A very complete Discord bot (more than 100 commands) that uses the Discord.js",
"main": "index.js", "main": "index.js",
"private": true, "private": true,