问题
I have some issues understanding the Discord.JS module, I have no clue of how to connect my bot to a server, even after looking at a lot of documentaries!
var Discord = require ( 'discord.js' ),
Client = new Discord.Client ( );
Client.on ( 'ready', () => {
console.log ( Client.channels.get ( '***ChannelID***' ) );
});
Client.login ( '***TOKEN***' );
Output:
undefined
Where getting the channel returns undefined
even I pass the correct id.
I don't know if the bot can connect to it without being invited to the server, and can't seem to find anything on it either?
Thanks!
回答1:
Bots must be in a server to get an ID
Example (Sorry my bot is in python but it is similar in the way it uses API):
This is because my bot is in the second channel but the first is made up
来源:https://stackoverflow.com/questions/42321485/discord-js-getting-channel-object-returns-undefined