Closed Nintega21 closed 5 years ago
Looks like you didn't set up auth.json properly (it fails to load the data in from it)
hey! go back to your token auth.json and make sure you have used " and not “. That was what was throwing mine. Same issue and error and everything!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is my code
var Discord = require('discord.io'); var logger = require('winston'); var auth = require('./auth.json'); logger.remove(logger.transports.Console); logger.add(new logger.transports.Console, { colorize: true }); logger.level = 'debug'; 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 + ')'); }); bot.on('message', function (user, userID, channelID, message, evt) { if (message.substring(0, 1) == 'esc!') { var args = message.substring(1).split(' '); var cmd = args[0];
} });
But for some reason, whenever I node bot.js this happens!
SyntaxError: C:\Users\Jai\Desktop\Escar-bot\auth.json: Unexpected token � in JSON at position 3 at JSON.parse () at Object.Module._extensions..json (internal/modules/cjs/loader.js:741:27) at Module.load (internal/modules/cjs/loader.js:620:32) at tryModuleLoad (internal/modules/cjs/loader.js:560:12) at Function.Module._load (internal/modules/cjs/loader.js:552:3) at Module.require (internal/modules/cjs/loader.js:658:17) at require (internal/modules/cjs/helpers.js:22:18) at Object. (C:\Users\Jai\Desktop\Escar-bot\bot.js:3:12) at Module._compile (internal/modules/cjs/loader.js:722:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
Not Sure why this is happening, Please help! And the unexpected token is just a question mark icon, so I can't even tell what the token is!