由于括号,我几乎可以肯定会收到此错误,但我无法解决。我正在尝试制作一个播放音乐的 discord机器人:
const Discord = require('discord.js');
const client = new Discord.Client();
const PREFIX = '';
const ydtl = require("ytdl-core")
const Token = "(token here)";
var servers = {}
client.on('message', message =>{
console.log("ESTOU ONLINE CARALHO");
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case 'play':
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()};
});
}
if(!args[1]){
message.channel.send("Tens que por o link da musica CARALHO");
return;
}
if(!message.member.voiceChannel){
message.channel.send("precisas de estar num canal de voz pra fazeres isso OH BURRO");
return;
}
if(!servers[message.guild.id]) servers[message.guild.id] = {
queue:[]
}
var server = servers[message.guild.id];
server.queue.push(args[1])
if(!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection){
play(connection, message);
})
break;
}
我在这里遇到错误:client.login(Token);
。为什么?
答案 0 :(得分:0)
您似乎没有使用提供的代码登录API,请尝试在文件末尾添加client.login(Token);
。