2017-09-14 8 views
0

Leave-Befehl funktioniert nicht auf meinem Discord-Bot, der in JS geschrieben ist.Leave Command Discord JS

Dies ist der Code-Schnipsel, den ich benutze.

if(command == 'leave') { client.leaveVoiceChannel;

jedoch der Befehl, der Bot den Sprachkanal zu arbeiten scheint nicht verlassen machen sollte. Hier ist, wie ich den Code verwende.

const Eris = require('eris'); 
 
const client = new Eris(require('./config.json').token, { maxShards: 1 }); 
 
fs = require('fs') 
 
var stations = fs.readFileSync("./stations.txt", {"encoding": "utf-8"}).toString() 
 
client.connect(); 
 
client.on('ready',() => { 
 
\t console.log('Ready to go!') 
 
}) 
 
client.on('messageCreate', message => { 
 
\t if(message.author.bot) return; 
 
\t if(message.content.startsWith('!')) { 
 
\t \t let command = message.content.substring(1).split(" ")[0]; 
 
\t \t let args = message.content.substring(2 + command.length); 
 
     
 
     if(command == 'leave') { 
 
     client.leaveVoiceChannel; 
 
     } else if(command == 'streams') { 
 
\t \t \t message.channel.createMessage(stations); 
 
\t \t } else if(command == 'radio') { 
 
\t \t \t if(args == '') return message.channel.createMessage(`:exclamation: Please specify the radio stream example: **!radio <stream> or use command **!streams** to see list.`); 
 
\t \t \t if(require('./stations.json')[args]) { 
 
\t \t \t \t if(!message.member.voiceState.channelID) return message.channel.createMessage(`:exclamation: You need to be in a voice channel to play that stream.`); 
 
\t \t \t \t client.joinVoiceChannel(message.member.voiceState.channelID).then(vc => { 
 
\t \t \t \t \t if(vc.playing) vc.stopPlaying(); 
 
\t \t \t \t \t message.channel.createMessage(`:radio: You are listening to Streaming station **${args}**. To change the stream use **!radio <stream>**`); 
 
\t \t \t \t \t vc.play(require('./stations.json')[args]); 
 
\t \t \t \t }) 
 
\t \t \t } else { 
 
\t \t \t \t return message.channel.createMessage(`:frowning2: I cannot find a radio stream with that name. Make sure it has capitals and the correct spelling. Type **!streams** to see stream list.`);      
 
\t \t \t }     
 
\t \t } 
 
\t } 
 
})

Ich bin mir nicht sicher, wo ich hier falsch gehe.

+0

Sollte das nicht 'client.leaveVoiceChannel()' sein? Wie, ein Funktionsaufruf? – Pointy

+0

Danke für deinen Kommentar ja es ist ein Funktionsaufruf. Ich habe es geschafft, es zu beheben. – John

Antwort

1

if(command == 'stopstream') { 
 
     client.leaveVoiceChannel(message.member.voiceState.channelID); 
 
     message.channel.createMessage(`Thanks for tuning in!`); }