Comments (2)
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.
Hopefully that helps! (:
from discord-bot.
Thank you very much for the quick and helpful response, as well as the detailed tutorial!
from discord-bot.
Related Issues (20)
- /play command returns an error HOT 2
- discordJs dependency outdated HOT 4
- Not allowed to be used HOT 2
- TypeError [CommandInteractionOptionType]: Option "mode" is of type: 4; expected 3. HOT 1
- DisallowedIntents HOT 3
- Bot activity not working.
- Error: Cannot find module 'prism-media' HOT 7
- Not responding to commands
- Question: Can you show me an example on how to add a basic info command? HOT 2
- Playing Error HOT 7
- Discord player type error HOT 4
- different behaviour when installed via npm / pnpm HOT 2
- Bot Won't Play HOT 3
- Playing Error HOT 5
- Youtube Links not working HOT 9
- Bot stops song mid-playback then automatically disconnects HOT 2
- Bot wont deploy after starting HOT 12
- Error [TokenInvalid]: An invalid token was provided. HOT 2
- Bot connects, loads track, adds it to queue, says its playing the song and then queue finished instantly. No music is played. HOT 5
- Volume gets down every time the bot disconnects HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from discord-bot.