Skip to content

Instantly share code, notes, and snippets.

@Strandxo
Last active July 8, 2026 02:34
Show Gist options
  • Select an option

  • Save Strandxo/a8b1fb5a378decf9f4ab5fc23990ce47 to your computer and use it in GitHub Desktop.

Select an option

Save Strandxo/a8b1fb5a378decf9f4ab5fc23990ce47 to your computer and use it in GitHub Desktop.
Playing Music
module.exports = (bot) => {
bot.playCommand = (message, args) => {
const [song] = await bot.getSongs(args[0]);
const voiceChannel = message.member.voiceChannelID
if (!song) return message.channel.send("No songs found. try again!");
if (!voiceChannel) return message.channel.send("You need to be in a voice channel to play music.")
const player = await lavalink.join({
guild: message.guild.id,
channel: voiceChannel,
host: lavalink.nodes.first().host
}, { selfdeaf: true });
if (!player) return message.channel.send("Could not join");
player.play(song.track);
player.once("error", console.error);
player.once("end", async (data) => {
if(data.reason === "REPLACED") return;
message.channel.send("Song has ended...");
await player.leave(message.guild.id);
});
return message.channel.send(`Now playing: **${song.info.title}** by *${song.info.author}*`);
}
};
const axios = require("axios");
module.exports = (bot) => {
bot.getSongs = async (identifier) => {
const node = lavalink.nodes.first();
const {data} = await axios.get(`http://${node.host}:${node.port}/loadtracks`, {
params: {
identifier
},
headers: {
Authorization: node.password
}
});
return data.tracks;
};
bot.decodeTrack = async (track) => {
const node = lavalink.nodes.first();
const {data} = await axios.get(`http://${node.host}:${node.port}/decodetrack`, {
params: {
track
},
headers: {
Authorization: node.password
}
});
return data;
};
};
module.exports = {
config: {
name: "play",
aliases: ["p"],
description: "Play a song from youtube.",
accessableby: "Member",
category: "music",
usage: "<input>"
},
run: (bot, message, args) => {
return bot.playCommand(message, args);
}
}
@cleanlinkmedia

Copy link
Copy Markdown

Zombie Scavenger by Mx-Shell is an independent fan-made viral Zombie Scavenger AI short film, covering where to watch it, who made it, how it was created, and possible future Zombie games updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment