I'm trying to create a channel switch logger which allows me to specify a channel where the messages get posted.
So, for example, I create a TextChannel called "Channel Switches". When now a user changes voice channel, it should appear a message in this Channel. (eg. <USER> left channel <CHANNEL> and joined <CHANNEL>.
)
MY PROBLEM IS: I get no errors and the Bot is not responding...
Here my first try:
var Discord = require('discord.js');
var logger = require("winston");
var auth = require("./auth.json");
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
colorize: true
});
logger.level = "debug";
// Initialize Discord Bot
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on("ready", function(evt) {
logger.info("Connected");
logger.info("Logged in as: ");
logger.info(bot.username + " – (" + bot.id + ")");
console.log("Logged in as ${client.user.tag}!");
});
bot.on('voiceStateUpdate', (oldMember, newMember) => {
let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel
if (!oldUserChannel && newUserChannel) {
bot.channels.get('475330828466126848').send("User went form Channel" + oldUserChannel.name + "to the new" +
newUserChannel.name + "Channel");
}
});