Certain URLs Not Working

Starting today I've noticed an issue where 'query' is undefined, specifically in the loadTracks() function. if (query.startsWith("http://") || query.startsWith("https://")) ^ TypeError: Cannot read properties of undefined (reading 'startsWith') at \nodemodules\moonlink.js\dist\src\entities\Rest.js:23:23 This occurs when a YouTube link like https://www.youtube.com/watch?v=__ , https://youtu.be/___ , soundcloud.com, and deezer.com links Links work perfectly fine although from bandcamp.com or spotify.com I use this in my play.js to test URLs to make sure they're ok,
const urlPattern = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be|spotify\.com|soundcloud\.com|deezer\.com|bandcamp\.com)\/.+$/i;
const isLink = urlPattern.test(query);

if (isLink) {
const allowedSources = ['youtube.com', 'youtu.be', 'spotify.com', 'soundcloud.com', 'deezer.com', 'bandcamp.com'];
const domain = query.match(/:\/\/(www\.)?([^\/]+)/)[2];
if (!allowedSources.includes(domain)) {
return interaction.reply('The provided link is not from an allowed source!');
}
}
const urlPattern = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be|spotify\.com|soundcloud\.com|deezer\.com|bandcamp\.com)\/.+$/i;
const isLink = urlPattern.test(query);

if (isLink) {
const allowedSources = ['youtube.com', 'youtu.be', 'spotify.com', 'soundcloud.com', 'deezer.com', 'bandcamp.com'];
const domain = query.match(/:\/\/(www\.)?([^\/]+)/)[2];
if (!allowedSources.includes(domain)) {
return interaction.reply('The provided link is not from an allowed source!');
}
}
and search and load everything through
let req;
if (isLink) {
req = await client.manager.search(query);
} else {
req = await client.manager.search({
query,
source,
});
}
let req;
if (isLink) {
req = await client.manager.search(query);
} else {
req = await client.manager.search({
query,
source,
});
}
in Rest.js specifically, logging the value of query returns undefined in these cases. Does anybody have a clue as to what's going on? I'm new to Moonlink so I'm still a bit limited in what I know of it. Thank you
Solution:
``` let req; if (isLink) { req = await client.manager.search({ query }); } else {...
Jump to solution
3 Replies
1Lucas1.apk
1Lucas1.apk•8mo ago
good morning. good afternoon good night :) in v4 you hear a change
Solution
1Lucas1.apk
1Lucas1.apk•8mo ago
let req;
if (isLink) {
req = await client.manager.search({ query });
} else {
req = await client.manager.search({
query,
source,
});
}
let req;
if (isLink) {
req = await client.manager.search({ query });
} else {
req = await client.manager.search({
query,
source,
});
}
provincial-silver
provincial-silverOP•8mo ago
Worked perfectly, thank you so much!

Did you find this page helpful?