Advertisement
Pikachuun

discord.js error

Jan 26th, 2016
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /Users/Pikachuun/node_modules/discord.js/lib/Client/InternalClient.js:49
  2. InternalClient.prototype.updateDetails = function updateDetails(data){return this.apiRequest("patch",_Constants.Endpoints.ME,true,{avatar:this.resolver.resolveToBase64(data.avatar) || this.user.avatar,email:data.email || this.email,new_password:data.newPassword || null,password:data.password || this.password,username:data.username || this.user.username});}; //def setAvatar
  3.                                                                                                                                                                                                  ^
  4.  
  5. TypeError: Cannot read property 'avatar' of undefined
  6.     at InternalClient.updateDetails (/Users/Pikachuun/node_modules/discord.js/lib/Client/InternalClient.js:49:194)
  7.     at InternalClient.setUsername (/Users/Pikachuun/node_modules/discord.js/lib/Client/InternalClient.js:51:83)
  8.     at Client.setUsername (/Users/Pikachuun/node_modules/discord.js/lib/Client/Client.js:68:183)
  9.     at Object.<anonymous> (/Users/Pikachuun/.qliphoth_choonbot/discord/choonbot.js:61:10)
  10.     at Module._compile (module.js:434:26)
  11.     at Object.Module._extensions..js (module.js:452:10)
  12.     at Module.load (module.js:355:32)
  13.     at Function.Module._load (module.js:310:12)
  14.     at Function.Module.runMain (module.js:475:10)
  15.     at startup (node.js:117:18)
  16.  
  17. /////////////////////////////////////////////
  18. //Choonbot.js
  19. /////////////////////////////////////////////
  20. 'use strict';
  21.  
  22. //Down here, I'm called...
  23. const NAMAE = "ChoonBot";
  24.  
  25. //global function init
  26. global.Discord = require('discord.js');
  27. global.fs = require('fs');
  28. global.request = require('superagent');
  29. global.toId = function (str) {
  30.     if (str && str.id) {
  31.         str = str.id;
  32.     } else if (str && str.userid) {
  33.         str = str.userid;
  34.     }
  35.     if (typeof str !== 'string' && typeof str !== 'number') return '';
  36.     return ('' + str).toLowerCase().replace(/[^a-z0-9]+/g, '');
  37. };
  38. global.getUsers = function () {
  39.     let usertxt = fs.readFileSync('./users.txt').toString();
  40.     if (!usertxt.split('raisin is best waifu and if you disagree your bad!!!!!!11!!!\n\n')[1]) return false;
  41.     usertxt = usertxt.split('raisin is best waifu and if you disagree your bad!!!!!!11!!!\n\n')[1];
  42.     console.log("Ping!");
  43.     return usertxt;
  44. };
  45. global.uncacheTree = function (root) {
  46.     var uncache = [require.resolve(root)];
  47.     do {
  48.         var newuncache = [];
  49.         for (var i = 0; i < uncache.length; ++i) {
  50.             if (require.cache[uncache[i]]) {
  51.                 newuncache.push.apply(newuncache,
  52.                     require.cache[uncache[i]].children.map(function (module) {
  53.                         return module.filename;
  54.                     })
  55.                 );
  56.                 delete require.cache[uncache[i]];
  57.             }
  58.         }
  59.         uncache = newuncache;
  60.     } while (uncache.length > 0);
  61. };
  62. global.choonbot = new Discord.Client();
  63. global.commands = require('./recognition.js').commands;
  64. global.emotes = require('./recognition.js').emotes;
  65. try {
  66.     global.configBuffer = require('./config.js');
  67. } catch (e) {
  68.     console.log('config.js doesn\'t exist; try copying config-base.js to config.js.');
  69.     process.exit(-1);
  70. }
  71. for (var i in configBuffer) {
  72.     global[i] = configBuffer[i];
  73. }
  74. delete global.configBuffer;
  75. global.games = {};
  76. global.unripAlready = {};
  77. choonbot.setUsername("ChoonBot");
  78. global.spoon = false;
  79. //check for users.txt
  80. let users = fs.readFileSync('./users.txt');
  81. //ok
  82. users = getUsers();
  83.  
  84. //And thus we begin.
  85. choonbot.on("ready", function () {
  86.     console.log("Ready to go! ('.w.') C:" + choonbot.channels.length);
  87. });
  88. choonbot.on("disconnected", function () {
  89.     console.log("rip in kill [dc]");
  90.     process.exit(1); //rip in kill
  91. });
  92. choonbot.on("message", function (message) {
  93.     //Update users
  94.     users = getUsers();
  95.     //No need to check ourselves. We already rekt ourselves.
  96.     if (message.sender.id === selfID) return false;
  97.     if (message.channel.id in antipost) return false;
  98.     if (message.channel.server.id in serverCrosstalk) {
  99.         let crosstalk = false;
  100.         for (let i = 0; i < serverCrosstalk[message.channel.server.id].length; i++) {
  101.             if (message.channel.id === serverCrosstalk[message.channel.server.id][i]) crosstalk = true;
  102.         }
  103.         if (!crosstalk) return false;
  104.     }
  105.     let msg = message.content;
  106.     if (!verbose) {
  107.         console.log("Message Intercept in #" + message.channel.name + " from @" + message.sender.username + ": " + msg);
  108.     } else {
  109.         console.log("Message Intercept in " + message.channel + " from " + message.sender + ": " + msg);
  110.     }
  111.     let msgbackup = msg;
  112.     for (let i = 0; i < cmdS.length; i++) {
  113.         if (msg.substr(0, cmdS[i].length) === cmdS[i]) {
  114.             msg = msg.substr(cmdS[i].length, msg.length).split(" ")[0].toLowerCase(); //grab the command from *command args
  115.             if (msg in commands) {
  116.                 let args = msgbackup;
  117.                 if (!args.substr(cmdS[i].length, args.length).split(" ")[1]) {
  118.                     args = [];
  119.                 } else {
  120.                     args = args.substr(cmdS[i].length, args.length).split(" ");
  121.                     if (args.length > 2) { //bug workaround
  122.                         let buffer = '';
  123.                         for (let i = 2; i < args.length; i++) {
  124.                             args[1] += " " + args[i];
  125.                         }
  126.                     }
  127.                     args = args[1].split(", ");
  128.                 }
  129.                 console.log("CMD:" + msg + "/ARG:" + args);
  130.                 if (!commands[msg].isHmm && message.channel.id in onlyHmm || commands[msg].isHmm && !(message.channel.id in onlyHmm)) return false;
  131.                 if (commands[msg].isSpam && message.channel.id in noSpam) return false;
  132.                 if (commands[msg].alias && commands[commands[msg].alias]) return commands[commands[msg].alias].command(message, args);
  133.                 return commands[msg].command(message, args);
  134.             }
  135.         }
  136.     }
  137.     if (msg.toLowerCase() === "h") { //Press H to hug.
  138.         return commands.hug.command(message, []);
  139.     }
  140.     if (message.everyoneMentioned) {
  141.         choonbot.reply(message, "YOU ARE LITERALLY THE WORST KIND OF PERSON FOR USING THE EVERYONE TAG");
  142.     } else {
  143.         for (var i in message.mentions) {
  144.             if (message.mentions[i].id === selfID) choonbot.reply(message, "you called?")
  145.         }
  146.     }
  147.     msg = msgbackup;
  148.     if (emtS[0] !== emtS[1] && msg.split(emtS[0])[1]) {
  149.         console.log("Emote Checksum 1 Passed.");
  150.         msg = msg.split(emtS[0])[1];
  151.         if (msg.split(emtS[1])[1] || msg[msg.length - 1] === emtS[1]) {
  152.             console.log("Emote Checksum 2 Passed.");
  153.             msg = msg.split(emtS[0])[0];
  154.             if (toId(msg) in emotes) {
  155.                 console.log("Emote Detected (" + toId(msg) + ")! Sending " + emotes[toId(msg)].emote + ".");
  156.                 if (emotes[toId(msg)].type === "text") return choonbot.sendMessage(message.channel, emotes[toId(msg)].emote);
  157.                 if (emotes[toId(msg)].type === "file") return choonbot.sendFile(message.channel, emotes[toId(msg)].emote, emotes[toId(msg)].name);
  158.             }
  159.         } else {
  160.             let err = 1*!(msg.split(emtS[1])[1]) + 2*(msg[msg.length - 1] !== emtS[1]);
  161.             console.log("Emote Checksum 2 Failed. Cause of death: " + String(err&1) + String((err&2)/2));
  162.         }
  163.         msg = msgbackup;
  164.     } else if (emtS[0] === emtS[1] && (msg.split(emtS[0])[2] || msg.split(emtS[0])[1] && msg[msg.length - 1] === emtS[0])) {
  165.         console.log("Emote Checksum Q Passed.");
  166.         msg = msg.split(emtS[0])[1];
  167.         if (toId(msg) in emotes) {
  168.             console.log("Emote Detected (" + toId(msg) + ")! Sending " + emotes[toId(msg)].emote + ".");
  169.             if (emotes[toId(msg)].type === "text") return choonbot.sendMessage(message.channel, emotes[toId(msg)].emote);
  170.             if (emotes[toId(msg)].type === "file") return choonbot.sendFile(message.channel, emotes[toId(msg)].emote, emotes[toId(msg)].name);
  171.         }
  172.     }
  173. });
  174.  
  175. choonbot.login(EMAIL, PASSW);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement