Created
August 16, 2017 08:54
-
-
Save sudojunior/b1d9ba838e0ec7d850a2902ed2ea35f8 to your computer and use it in GitHub Desktop.
Discord to IRC and back.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"token": "", | |
"irc": { | |
"channel": "", | |
"username": "", | |
"pass": "" | |
}, | |
"discord": { | |
"guild": "", | |
"channel": "" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Carp = require("carp-irc") | |
const Discord = require('discord.js') | |
const Config = require('./config.json') | |
const Client = new Carp.Client({ | |
username: Config.irc.username, | |
pass: Config.irc.pass | |
}) | |
const Bot = new Discord.Client() | |
Client.on("ready", () => { | |
console.log("IRC Client online.") | |
Client.join("#discorddungeons") | |
}) | |
Bot.on('ready', () => { | |
console.log("Discord Client online.") | |
}) | |
Client.on("join", joinData => { | |
let channel = joinData.channel | |
let guild = Bot.guilds.get('346385992674050058').channels.get('347057875702775811') | |
channel.on("message", (from, message) => { | |
if(from.info.nickname === Client.info.username) {return} | |
guild.send(`**<${from.info.nick}>** ${message}`) | |
console.log(`[IRC] ${channel.name} | ${from.info.nick}: ${message}`) | |
}) | |
channel.on('join', (user) => { | |
guild.send(`**${user.info.nick}** joined #discorddungeons`) | |
console.log(`[IRC] ${user.info.nick} joined ${channel.name}`) | |
}) | |
channel.on('part', (user, message) => { | |
guild.send(`**${user.info.nick}** left ${channel.name}`) | |
console.log(`[IRC] ${user.info.nick} left ${channel.name}`) | |
}) | |
channel.on('+mode', (user, from, modes) => { | |
guild.send(`**${from} gives **${user}** the flag(s) ${modes.join(', ')}`) | |
console.log(`${from} gives ${user} the flag(s) ${modes.join(', ')}`) | |
}) | |
channel.on('-mode', (user, from ,modes) => { | |
guild.send(`**${from}** removes **${user}** the flag(s) ${modes.join(', ')}`) | |
console.log(`${from} removes ${user} the flag(s) ${modes.join(', ')}`) | |
}) | |
Bot.on('message', msg => { | |
if(msg.author.bot) {return} | |
if(msg.channel.id !== '347057875702775811') {return} | |
channel.sendMessage(`${msg.author.tag}: ${msg.content}`) | |
console.log(`[Discord] ${msg.guild.name} | ${msg.channel.name} | ${msg.author.tag}: ${msg.content}`) | |
}) | |
}) | |
Client.connect("irc.freenode.net") | |
Bot.login(Config.token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment