Says 'Please provide a link" after i put a link in?
See original GitHub issueconst Discord = require(‘discord.js’); const YTDL = require(‘ytdl-core’);
const TOKEN = “NDA5OTc4Mjg2NjkzNjc5MTA0.DVmdow.yI4l0Z2UtZ2RgSBJqeWjkUtg7I0”; const PREFIX = “dm.”;
function play(connection, message) { var server = servers[message.guild.id]
server.dispatcher = connection.playStream(YTDL(server.queue[0], {filter: "audioonly"}));
server.queue.shift()
server.dispatcher.on("end", function() {
if (!server.queue[0]) play(connection, message);
else connection.disconnect();
});
}
const bot = new Discord.Client()
const servers = {};
bot.on(“ready”, function() { console.log(“I’m ready to play music !”)
bot.user.setPresence({game: {name: Bot In Development | Users: ${bot.users.size}
,type: 0}});
bot.on(‘message’, function(message) { if (message.author.equals(bot.user)) return;
if (!message.content.startsWith(PREFIX)) return;
var args = message.content.substring(PREFIX.length).split(" ");
switch (args[0].toLowerCase()) {
case "play":
if (args[1]) {
message.channel.send('Please provide a link!');
return;
}
if (!message.member.voiceChannel) {
message.channel.send('You must be in a voice channel!');
return;
}
if(servers[message.guild.id]) servers[message.guild.id] = {
queue: []
};
var server = servers[message.guild.id]
if (!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection) {
play(connection, message);
});
break;
case "skip":
var server = servers[message.guild.id];
if (server.dispatcher) server.dispatcher.end();
break;
case "stop":
var server = servers[message.guild.id];
if(!message.guild.voiceConnection) message.guild.voiceConnection.disconnect();
break;
}
})})
bot.login(TOKEN);
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Create or edit a hyperlink - Microsoft Support
The fastest way to create a basic hyperlink in a Microsoft 365 document is to press ENTER or the SPACEBAR after you type...
Read more >HTML Link – How to Insert a Link to a Website with HREF Code
We'll learn how to create a hyperlink for this use case when we learn about the href attribute. 2. When you want to...
Read more >Fix a Broken Link in Your Email (After You've Hit Send)
Did you send a marketing email with a bad or broken link? Here are three ways you can fix it after you've already...
Read more >How to Add a Hyperlink to an Email - GroupMail
When a recipient of your email clicks on Click Here, it will take them to the website that you entered as the hyperlink....
Read more >Beginner's Guide on How to Add a Link in WordPress
Once you create a new post or edit an existing one, you should click the (+) icon to create a new block. After...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@GamerXD4 I would reset your token IMMIDEATLY as you’ve just given it away on a public platform, and users will abuse it by destroying anything the bot is connected on.
With that out of the way, make sure “server.queue[0]” is returning a valid YouTube URL. Try using
console.log(server.queue[0]);
before running it and send the results here.Here’s his code cleaned up and put into one code block:
None of this is related to ytdl-core but whatever
A few of your problems
=> if a link is provided, respond there is no link
=> server can be undefined when skipping
=> better add it when it’s not in there
=> better use a Map for this
UR never pushing items to ur music q nether validating/handling ytdl’s video not found errors
=> when we have nothing in the q play it?