Justin
Justin
Explore posts from servers
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 3/16/2025 in #help
Spotify 'query' not working, link works with playing
That worked, thanks!
13 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 3/16/2025 in #help
Spotify 'query' not working, link works with playing
So like this?
const res = await client.moonlink.search({ query, source: "spsearch", requester: interaction.user.id });
const res = await client.moonlink.search({ query, source: "spsearch", requester: interaction.user.id });
13 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 3/16/2025 in #help
Spotify 'query' not working, link works with playing
The actual code:
import { SlashCommandBuilder, EmbedBuilder, Colors } from "discord.js";
import { client } from "../../bot";

function createEmbed({ color, author, description }) {
return new EmbedBuilder()
.setColor(color)
.setAuthor({ name: author.name, iconURL: author.iconURL })
.setDescription(description);
}

export const data = new SlashCommandBuilder()
.setName("play")
.setDescription("Play a song in your voice channel.")
.addStringOption(option =>
option.setName("query")
.setDescription("The song you want to play.")
.setRequired(true)
);

export async function execute(interaction) {
const embedOptions = {
author: { iconURL: interaction.client.user.displayAvatarURL() },
ephemeral: true,
};

if (!interaction.member.voice.channel) {
return interaction.reply(createEmbed({ color: Colors.Yellow, author: { ...embedOptions.author, name: "🚨 Hold up!" }, description: "You need to be in a voice channel to use this command." }));
}

const query = interaction.options.getString("query");

if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\//.test(query)) {
return interaction.reply(createEmbed({ color: Colors.Red, author: { ...embedOptions.author, name: "❌ Oops! YouTube isn't allowed" }, description: "Sorry, but I can't play YouTube links. Please use another source instead." }));
}

const player = client.moonlink.createPlayer({
guildId: interaction.guild.id,
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoPlay: true
});

if (!player.connected) {
player.connect({ setDeaf: true, setMute: false });
}

try {
const res = await client.moonlink.search({ query, source: "spotify", requester: interaction.user.id });

if (res.loadType === "loadfailed" || res.loadType === "empty") {
const errorDescription = res.loadType === "loadfailed"
? "Something went wrong while searching for your track."
: "Oops! I couldn't find anything matching your query.";

return interaction.reply(createEmbed({ color: res.loadType === "loadfailed" ? Colors.Red : Colors.Blue, author: { ...embedOptions.author, name: "⚠️ Something went wrong" }, description: errorDescription }));
}

const embed = new EmbedBuilder().setColor(Colors.Blue);
if (res.loadType === "playlist") {
embed.setAuthor({ name: `🎶 Playlist Added: ${res.playlistInfo.name}`, iconURL: embedOptions.author.iconURL })
.setDescription(`Added ${res.tracks.length} tracks to the queue.`);
res.tracks.forEach(track => player.queue.add(track));
} else {
player.queue.add(res.tracks[0]);
embed.setAuthor({ name: `🎵 Track Added: ${res.tracks[0].title}`, iconURL: embedOptions.author.iconURL })
.setURL(res.tracks[0].url)
.setThumbnail(res.tracks[0].artworkUrl)
.addFields(
{ name: "Duration", value: res.tracks[0].isStream ? "LIVE" : `${Math.floor(res.tracks[0].duration / 1000)}s`, inline: true },
{ name: "Requested by", value: `<@${interaction.user.id}>`, inline: true }
);
}

interaction.reply({ embeds: [embed] });
if (!player.playing) player.play();
} catch (error) {
console.error("Error while playing track:", error);
interaction.reply(createEmbed({ color: Colors.Red, author: { ...embedOptions.author, name: "⚠️ Uh-oh, something went wrong..." }, description: "Whoops, something went wrong while trying to play that track." }));
}
}
import { SlashCommandBuilder, EmbedBuilder, Colors } from "discord.js";
import { client } from "../../bot";

function createEmbed({ color, author, description }) {
return new EmbedBuilder()
.setColor(color)
.setAuthor({ name: author.name, iconURL: author.iconURL })
.setDescription(description);
}

export const data = new SlashCommandBuilder()
.setName("play")
.setDescription("Play a song in your voice channel.")
.addStringOption(option =>
option.setName("query")
.setDescription("The song you want to play.")
.setRequired(true)
);

export async function execute(interaction) {
const embedOptions = {
author: { iconURL: interaction.client.user.displayAvatarURL() },
ephemeral: true,
};

if (!interaction.member.voice.channel) {
return interaction.reply(createEmbed({ color: Colors.Yellow, author: { ...embedOptions.author, name: "🚨 Hold up!" }, description: "You need to be in a voice channel to use this command." }));
}

const query = interaction.options.getString("query");

if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\//.test(query)) {
return interaction.reply(createEmbed({ color: Colors.Red, author: { ...embedOptions.author, name: "❌ Oops! YouTube isn't allowed" }, description: "Sorry, but I can't play YouTube links. Please use another source instead." }));
}

const player = client.moonlink.createPlayer({
guildId: interaction.guild.id,
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoPlay: true
});

if (!player.connected) {
player.connect({ setDeaf: true, setMute: false });
}

try {
const res = await client.moonlink.search({ query, source: "spotify", requester: interaction.user.id });

if (res.loadType === "loadfailed" || res.loadType === "empty") {
const errorDescription = res.loadType === "loadfailed"
? "Something went wrong while searching for your track."
: "Oops! I couldn't find anything matching your query.";

return interaction.reply(createEmbed({ color: res.loadType === "loadfailed" ? Colors.Red : Colors.Blue, author: { ...embedOptions.author, name: "⚠️ Something went wrong" }, description: errorDescription }));
}

const embed = new EmbedBuilder().setColor(Colors.Blue);
if (res.loadType === "playlist") {
embed.setAuthor({ name: `🎶 Playlist Added: ${res.playlistInfo.name}`, iconURL: embedOptions.author.iconURL })
.setDescription(`Added ${res.tracks.length} tracks to the queue.`);
res.tracks.forEach(track => player.queue.add(track));
} else {
player.queue.add(res.tracks[0]);
embed.setAuthor({ name: `🎵 Track Added: ${res.tracks[0].title}`, iconURL: embedOptions.author.iconURL })
.setURL(res.tracks[0].url)
.setThumbnail(res.tracks[0].artworkUrl)
.addFields(
{ name: "Duration", value: res.tracks[0].isStream ? "LIVE" : `${Math.floor(res.tracks[0].duration / 1000)}s`, inline: true },
{ name: "Requested by", value: `<@${interaction.user.id}>`, inline: true }
);
}

interaction.reply({ embeds: [embed] });
if (!player.playing) player.play();
} catch (error) {
console.error("Error while playing track:", error);
interaction.reply(createEmbed({ color: Colors.Red, author: { ...embedOptions.author, name: "⚠️ Uh-oh, something went wrong..." }, description: "Whoops, something went wrong while trying to play that track." }));
}
}
13 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 3/16/2025 in #help
Spotify 'query' not working, link works with playing
I'm using an publicly available Lavalink server for development purposes, I will switch to own one later, this is the one that I'm using.
Hosted by @ hatry4/naig - Version 4.0.8
Plugins: youtube-plugin:1.8.3, lavalyrics-plugin:1.0.0, lavasrc-plugin:4.2.0, sponsorblock-plugin:3.0.1, lavasearch-plugin:1.0.0, skybot-lavalink-plugin:1.7.0, java-lyrics-plugin:1.6.5, jiosaavn-plugin:v1.0.2 and Spotify API

Host : lavahatry4.techbyte.host
Port : 3000
Password : "NAIGLAVA-dash.techbyte.host"
Secure : false
Hosted by @ hatry4/naig - Version 4.0.8
Plugins: youtube-plugin:1.8.3, lavalyrics-plugin:1.0.0, lavasrc-plugin:4.2.0, sponsorblock-plugin:3.0.1, lavasearch-plugin:1.0.0, skybot-lavalink-plugin:1.7.0, java-lyrics-plugin:1.6.5, jiosaavn-plugin:v1.0.2 and Spotify API

Host : lavahatry4.techbyte.host
Port : 3000
Password : "NAIGLAVA-dash.techbyte.host"
Secure : false
13 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
Different question @1Lucas1.apk. Is it possible to apply filters to the music? Like making the music bass boosted or something like that?
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
ah so it's player.setVolume(boolean)?
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
And yes, I defined player.
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
Should be implemented right, this is my code; https://sourceb.in/0yhUYPDBHq
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
Huh, I did?
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
TypeError: player.volume is not a function ?
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
Entire different question right now. Is it possible to lower the volume of the audio/music (whatever is playing) of the discord bot? Like setting the volume to 50% or something like that.
202 replies
DIAdiscord.js - Imagine an app
Created by Justin on 10/9/2023 in #djs-voice
Issues with getting an guild ID
Ah sad. I'll look/request then if they can add a feature like that. Anyways thanks!
5 replies
DIAdiscord.js - Imagine an app
Created by Justin on 10/9/2023 in #djs-voice
Issues with getting an guild ID
I have a different command called 'play' that joins the voice channel throughout a lavalink-client package. So it's in theory already in a VoiceChannel, but that package doesn't support lowering the volume. So how can I do it then?
5 replies
DIAdiscord.js - Imagine an app
Created by Justin on 10/9/2023 in #djs-voice
Issues with getting an guild ID
- [email protected] and using node version v18.18.0 - I'm trying to make an /setvolume slash command to change the volume of the bot when it's playing its music. But I need to get the guild ID. I tried everytime all options, but just by console logging interaction.guild.id it returns with the guild id. When I put in the getVoiceConnection part it returns with undefined so how will I define the guild ID? - my entire code: https://sourceb.in/Y0YvSgomYF
5 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
Different question now, is it possible to change the messages of Moonlink.js?
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
I just copied over your code from the Github Repo, and it worked :NM_peepoShrugSmile:, so i don't know how i assigned them
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
client returns
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
undefined
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
alright one sec
202 replies
MIA🎶 Moonlink.js - Imagine a Music Application
Created by Justin on 10/8/2023 in #help
Bot disconnects
It keeps giving me this error, TypeError: Cannot read properties of undefined (reading 'players')
202 replies