Added support for youtube playlists, replaced multiple fetch requests with lavacord rest helpers
This commit is contained in:
parent
c59a0bf0c4
commit
4caad42240
3 changed files with 9 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
|||
import fetch from "node-fetch";
|
||||
import { Rest } from "lavacord";
|
||||
import format from "format-duration";
|
||||
import MusicCommand from "../../classes/musicCommand.js";
|
||||
|
||||
|
@ -11,7 +11,7 @@ class NowPlayingCommand extends MusicCommand {
|
|||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
const player = this.connection.player;
|
||||
if (!player) return "I'm not playing anything!";
|
||||
const track = await fetch(`http://${player.node.host}:${player.node.port}/decodetrack?track=${encodeURIComponent(player.track)}`, { headers: { Authorization: player.node.password } }).then(res => res.json());
|
||||
const track = await Rest.decode(player.node, player.track);
|
||||
const parts = Math.floor((player.state.position / track.length) * 10);
|
||||
return {
|
||||
"embed": {
|
||||
|
|
|
@ -10,7 +10,7 @@ class PlayCommand extends MusicCommand {
|
|||
if (!this.args[0]) return "You need to provide what you want to play!";
|
||||
const query = this.args.join(" ").trim();
|
||||
const search = urlRegex.test(query) ? query : (searchRegex.test(query) ? query : `ytsearch:${query}`);
|
||||
return await play(this.client, encodeURIComponent(search), this.message, true);
|
||||
return await play(this.client, search, this.message, true);
|
||||
}
|
||||
|
||||
static description = "Plays a song or adds it to the queue";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue