You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Everything works as intended, so thank you for that.
To note: my prefix is ( . )
The .play <YT URL video ID> function works perfectly, but I would like to know how to create a message return when needed:
(1) When .play is entered alone or .play <Song title>, I want to return a message to the user stating to enter a valid YT URL in order for the function to work.
(a) Also but not as important, I would like to get rid of the console errors that stem from not entering .play <YT URL video ID> exactly (unhandlePromiseRejectionWarnings).
Thank you for your time!
The text was updated successfully, but these errors were encountered:
Hi, what you’re looking for is a function to validate whether or not args[1] is a YouTube URL.
Here’s a function that will do so.
function validateYouTubeUrl()
{
var url = $('#youTubeUrl').val();
if (url != undefined || url != '') {
var regExp = /^.(youtu.be/|v/|u/\w/|embed/|watch?v=|&v=|?v=)([^#\&\?]).*/;
var match = url.match(regExp);
if (match && match[2].length == 11) {
// Do anything for being valid
// if need to change the url to embed url then use below line
$('#ytplayerSide').attr('src', 'https://www.youtube.com/embed/' + match[2] + '?autoplay=0');
}
else {
// Do anything for not being valid
}
}
}
Replace the //Do anything for not being valid with
message.channel.send(“Enter valid Youtube URL”)
And //Do anything for being valid with the function to perform the !play command.
Hello,
Everything works as intended, so thank you for that.
To note: my prefix is ( . )
The
.play <YT URL video ID>
function works perfectly, but I would like to know how to create a message return when needed:(1) When .play is entered alone or
.play <Song title>
, I want to return a message to the user stating to enter a valid YT URL in order for the function to work.(a) Also but not as important, I would like to get rid of the console errors that stem from not entering
.play <YT URL video ID>
exactly (unhandlePromiseRejectionWarnings).Thank you for your time!
The text was updated successfully, but these errors were encountered: