Added remove, fixed reload and broadcast
This commit is contained in:
parent
e179b923f0
commit
514166c79f
5 changed files with 29 additions and 7 deletions
|
@ -16,7 +16,7 @@ class ReloadCommand extends Command {
|
|||
this.ipc.register("reloadFail", (message) => {
|
||||
this.ipc.unregister("reloadSuccess");
|
||||
this.ipc.unregister("reloadFail");
|
||||
resolve(message.msg.result);
|
||||
resolve(message.result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { queues } from "../../utils/soundplayer.js";
|
||||
//import { Rest } from "lavacord";
|
||||
import fetch from "node-fetch";
|
||||
import format from "format-duration";
|
||||
|
@ -11,10 +10,9 @@ class QueueCommand extends MusicCommand {
|
|||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
||||
const queue = queues.get(this.message.channel.guild.id);
|
||||
const player = this.connection;
|
||||
//const tracks = await Rest.decode(player.player.node, queue);
|
||||
const tracks = await fetch(`http://${player.player.node.host}:${player.player.node.port}/decodetracks`, { method: "POST", body: JSON.stringify(queue), headers: { Authorization: player.player.node.password, "Content-Type": "application/json" } }).then(res => res.json());
|
||||
const tracks = await fetch(`http://${player.player.node.host}:${player.player.node.port}/decodetracks`, { method: "POST", body: JSON.stringify(this.queue), headers: { Authorization: player.player.node.password, "Content-Type": "application/json" } }).then(res => res.json());
|
||||
const trackList = [];
|
||||
const firstTrack = tracks.shift();
|
||||
for (const [i, track] of tracks.entries()) {
|
||||
|
|
23
commands/music/remove.js
Normal file
23
commands/music/remove.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Rest } from "lavacord";
|
||||
import { queues } from "../../utils/soundplayer.js";
|
||||
import MusicCommand from "../../classes/musicCommand.js";
|
||||
|
||||
class RemoveCommand extends MusicCommand {
|
||||
async run() {
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
if (this.connection.host !== this.message.author.id) return "Only the current voice session host can remove songs from the queue!";
|
||||
const pos = parseInt(this.args[0]);
|
||||
if (isNaN(pos) || pos > this.queue.length || pos < 1) return "That's not a valid position!";
|
||||
const removed = this.queue.splice(pos, 1);
|
||||
const track = await Rest.decode(this.connection.player.node, removed[0]);
|
||||
queues.set(this.message.channel.guild.id, this.queue);
|
||||
return `🔊 The song \`${track.title !== "" ? track.title : "(blank)"}\` has been removed from the queue.`;
|
||||
}
|
||||
|
||||
static description = "Removes a song from the queue";
|
||||
static aliases = ["rm"];
|
||||
}
|
||||
|
||||
export default RemoveCommand;
|
Loading…
Add table
Add a link
Reference in a new issue