Repository: reactiflux/discord-irc (js)

Issue:
No way to login with a token
There currently doesn't appear to be a way to login to discord with a token on an API application account. :/

Pull request:
Changes the bot to use discords API
Fixes #58 :-D

Patch:
diff --git a/README.md b/README.md
index 88523a3..f85f15b 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,6 @@ or by cloning the repository:
 ```bash
 In the repository folder:
 $ npm install
-$ npm run build # Transpile ES6 to ES5 using Babel
 $ npm start -- --config /path/to/config.json # Note the extra double dash
 ```
 
@@ -31,7 +30,7 @@ discordIRC(config);
 ```
 
 ## Configuration
-Create a discord user and join the server you want to connect to IRC.
+Create a discord bot [(how to here)](https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token) & register a nick for IRC.
 
 ### Example configuration
 ```js
@@ -40,8 +39,7 @@ Create a discord user and join the server you want to connect to IRC.
   {
     "nickname": "test2",
     "server": "irc.testbot.org",
-    "discordEmail": "user@mail.com",
-    "discordPassword": "letmein123",
+    "discordToken: "botwantsin123",
     "channelMapping": {
       "#other-discord": "#new-irc-channel"
     }
@@ -51,8 +49,7 @@ Create a discord user and join the server you want to connect to IRC.
   {
     "nickname": "test",
     "server": "irc.bottest.org",
-    "discordEmail": "user@mail.com",
-    "discordPassword": "letmein123",
+    "discordToken": "botwantsin123",
     "autoSendCommands": [ // Commands that will be sent on connect
       ["PRIVMSG", "NickServ", "IDENTIFY password"],
       ["MODE", "test", "+x"],
diff --git a/lib/bot.js b/lib/bot.js
index fc5580a..fecf4ba 100644
--- a/lib/bot.js
+++ b/lib/bot.js
@@ -5,7 +5,7 @@ import discord from 'discord.js';
 import { ConfigurationError } from './errors';
 import { validateChannelMapping } from './validators';
 
-const REQUIRED_FIELDS = ['server', 'nickname', 'channelMapping', 'discordEmail', 'discordPassword'];
+const REQUIRED_FIELDS = ['server', 'nickname', 'channelMapping', 'discordToken'];
 const NICK_COLORS = ['light_blue', 'dark_blue', 'light_red', 'dark_red', 'light_green',
   'dark_green', 'magenta', 'light_magenta', 'orange', 'yellow', 'cyan', 'light_cyan'];
 
@@ -28,8 +28,7 @@ class Bot {
     this.server = options.server;
     this.nickname = options.nickname;
     this.ircOptions = options.ircOptions;
-    this.discordEmail = options.discordEmail;
-    this.discordPassword = options.discordPassword;
+    this.discordToken = options.discordToken;
     this.commandCharacters = options.commandCharacters || [];
     this.ircNickColor = options.ircNickColor !== false; // default to true
     this.channels = _.values(options.channelMapping);
@@ -47,7 +46,7 @@ class Bot {
 
   connect() {
     logger.debug('Connecting to IRC and Discord');
-    this.discord.login(this.discordEmail, this.discordPassword);
+    this.discord.loginWithToken(this.discordToken);
 
     const ircOptions = {
       userName: this.nickname,
diff --git a/package.json b/package.json
index f7a2ee5..8186e69 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
     "commander": "2.9.0",
     "discord.js": "7.0.1",
     "irc": "0.5.0",
-    "lodash": "4.11.1",
+    "lodash": "4.11.2",
     "strip-json-comments": "2.0.1",
     "winston": "2.2.0"
   },
@@ -55,7 +55,7 @@
     "eslint-config-webkom": "^1.3.4",
     "mocha": "2.4.5",
     "nyc": "^6.1.1",
-    "sinon": "1.17.3",
+    "sinon": "1.17.4",
     "sinon-chai": "2.8.0"
   }
 }


Test patch:
diff --git a/test/fixtures/bad-config.json b/test/fixtures/bad-config.json
index e48121c..57740da 100644
--- a/test/fixtures/bad-config.json
+++ b/test/fixtures/bad-config.json
@@ -1,7 +1,7 @@
 [
   {
     "server": "irc.bottest.org",
-    "token": "hei",
+    "discordToken": "hei",
     "channelMapping": {
       "#discord": "#irc"
     }
diff --git a/test/fixtures/case-sensitivity-config.json b/test/fixtures/case-sensitivity-config.json
index 4cab69b..f5f4ded 100644
--- a/test/fixtures/case-sensitivity-config.json
+++ b/test/fixtures/case-sensitivity-config.json
@@ -1,8 +1,7 @@
 {
   "nickname": "Reactiflux",
   "server": "irc.freenode.net",
-  "discordEmail": "discord@test.com",
-  "discordPassword": "whatapassword",
+  "discordToken": "discord@test.com",
   "commandCharacters": ["!", "."],
   "autoSendCommands": [
     ["MODE", "test", "+x"],
diff --git a/test/fixtures/single-test-config.json b/test/fixtures/single-test-config.json
index 69525df..fa09687 100644
--- a/test/fixtures/single-test-config.json
+++ b/test/fixtures/single-test-config.json
@@ -1,8 +1,7 @@
 {
   "nickname": "Reactiflux",
   "server": "irc.freenode.net",
-  "discordEmail": "discord@test.com",
-  "discordPassword": "whatapassword",
+  "discordToken": "whatapassword",
   "commandCharacters": ["!", "."],
   "autoSendCommands": [
     ["MODE", "test", "+x"],
diff --git a/test/fixtures/test-config-comments.json b/test/fixtures/test-config-comments.json
index 9417047..0d05e7a 100644
--- a/test/fixtures/test-config-comments.json
+++ b/test/fixtures/test-config-comments.json
@@ -2,8 +2,7 @@
   {
     "nickname": "test",
     "server": "irc.freenode.net",
-    "discordEmail": "discord@test.com",
-    "discordPassword": /* comment */ "whatapassword",
+    "discordToken": /* comment */ "whatapassword",
     "channelMapping": {
       "#discord": "#irc" // Comment
     }
@@ -12,8 +11,7 @@
   {
     "nickname": "test2",
     "server": "irc.freenode.net",
-    "discordEmail": "discord@test.com",
-    "discordPassword": "whatapassword",
+    "discordToken": "whatapassword",
     "channelMapping": {
       "#discord": "#irc"
     }
diff --git a/test/fixtures/test-config.json b/test/fixtures/test-config.json
index b9f037c..f306c9d 100644
--- a/test/fixtures/test-config.json
+++ b/test/fixtures/test-config.json
@@ -2,8 +2,7 @@
   {
     "nickname": "test",
     "server": "irc.freenode.net",
-    "discordEmail": "discord@test.com",
-    "discordPassword": "whatapassword",
+    "discordToken": "whatapassword",
     "channelMapping": {
       "#discord": "#irc"
     }
@@ -11,8 +10,7 @@
   {
     "nickname": "test2",
     "server": "irc.freenode.net",
-    "discordEmail": "discord@test.com",
-    "discordPassword": "whatapassword",
+    "discordToken": "whatapassword",
     "channelMapping": {
       "#discord": "#irc"
     }
diff --git a/test/fixtures/test-javascript-config.js b/test/fixtures/test-javascript-config.js
index 4aac1a4..8f42ee7 100644
--- a/test/fixtures/test-javascript-config.js
+++ b/test/fixtures/test-javascript-config.js
@@ -2,8 +2,7 @@ module.exports = [
   {
     nickname: 'test',
     server: 'irc.freenode.net',
-    discordEmail: 'discord@test.com',
-    discordPassword: 'whatapassword',
+    discordToken: 'whatapassword',
     channelMapping: {
       '#discord': '#irc'
     }
@@ -11,8 +10,7 @@ module.exports = [
   {
     nickname: 'test2',
     server: 'irc.freenode.net',
-    discordEmail: 'discord@test.com',
-    discordPassword: 'whatapassword',
+    discordToken: 'whatapassword',
     channelMapping: {
       '#discord': '#irc'
     }
diff --git a/test/stubs/discord-stub.js b/test/stubs/discord-stub.js
index dd8bc41..5101bd2 100644
--- a/test/stubs/discord-stub.js
+++ b/test/stubs/discord-stub.js
@@ -21,7 +21,7 @@ class DiscordStub extends events.EventEmitter {
     };
   }
 
-  login() {
+  loginWithToken() {
     return sinon.stub();
   }
 }