Giter VIP home page Giter VIP logo

discord2slack's Introduction

discord2slack (now unmaintained)

No Maintenance Intended

You should take a look at 42wim/matterbridge instead. If you still want to use this project, feel free to do so, but I don't intend to continue development on this. Thanks for your interest!

Send messages to Slack using Discord and vice versa.

Tested with Node v9.9.0.

Install

git clone https://github.com/aubguillemette/discord2slack.git && cd discord2slack
npm install
# Configure your stuff (see Config section)
npm start

Config

You have to set the following values in discord2slack.js

const DISCORD_TOKEN         = '';
const DISCORD_CHANNEL       = '';
const DISCORD_CHANNELID     = '';
const SLACK_TOKEN           = '';
const SLACK_CHANNEL         = '';
const SLACK_CHANNEL_PRIVATE = false;

...where

  • DISCORD_TOKEN is your Discord bot token
  • DISCORD_CHANNEL is the name of your Discord channel (configure this or DISCORD_CHANNELID)
  • DISCORD_CHANNELID is the ID of your Discord channel (configure this or DISCORD_CHANNEL)
  • SLACK_TOKEN is your Slack bot token
  • SLACK_CHANNEL is the name of your Slack channel
  • SLACK_CHANNEL_PRIVATE represents whether or not your Slack channel is private

How does one create Discord and Slack bots?

I've included instructions in the source code, I'll put them here too.

How to configure a Discord bot

  1. Go here: https://discordapp.com/developers/applications/me
  2. Create an app
  3. When the app is created, click on "Create a Bot User"
  4. Name bot, copy the Token, paste it in the conf. section of the source code and save changes.
  5. Go here (but replace "YOUR_CLIENT_ID" in the URL) https://discordapp.com/oauth2/authorize?client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=3072
  6. Choose the server you want to give your bot access to and click OK (or wtv the submit button is named)
  7. Go on Discord and configure your channel to give msg read and msg write permissions to your bot.
  8. Copy your Channel ID or your Channel Name and paste it in the conf. section of the source code.

How to configure a Slack bot

  1. Go to https://my.slack.com/services/new/bot
  2. Configure the name of the bot
  3. Copy-Paste the Token into the conf. section of the source code and save changes.
  4. Invite the bot to the desired channel (/invite @my-l33t-bot)
  5. Copy the channel name in the conf. section of the source code.
  6. If the channel is private, set SLACK_CHANNEL_PRIVATE to true.

TODO

  • Add support for DMs
  • Add support for multiple channels

discord2slack's People

Contributors

aubguillemette avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

discord2slack's Issues

Error: read ECONNRESET

events.js:292
throw er; // Unhandled 'error' event
^

Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on WebSocket instance at:
at ClientRequest.onerror (C:\Users\DELL\Downloads\discord2slack-master\node_modules\ws\lib\WebSocket.js:711:10)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:469:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}

Node : v14.16.0
NPM: 6.14.11

I receive the following code when I try to run the code. It ran initially but after that it never worked.

discord sends all messages to slack

Currently the bot sends all discord messages to a specific slack channel, it doesn't check in what discord channel a message is send.

A quick fix for this is to check if the channel where the message is send in does equal the channel specified in the configuration section under 'DISCORD_CHANNELID'

Example:

if (message.channel.id === DISCORD_CHANNELID) {
        ...
}

Wrong config on README file

In the Discord config I found point number 4 not correct.
Instead of Token + Client ID, Token is enough to make it work.

not working messages from slack

messages from discord working, but not from slack, channel is not private, also i wanted to reinstall so npm install didn't work.

No error if discord channel id not correct

I like the app. It would be nice if you mention what version nodeJs it requires or has been tested with. I installed this on debian and it started with nodejs 0.10 which obviously was too old, but upgrading to nodejs 6 seemed to work although some errors came up.

I dont use discord so I had no idea on how to get the channelId. That could be worth while to include that in the help somewhere because it was a bit involved going into dev mode.

With that said I initially tried the "Server Id" which didnt work but nothing told me that it didnt work. It wasnt until I messaged the bot I saw

TypeError: Cannot read property 'send' of undefined
    at /discord2slack/discord2slack.js:96:21
    at Array.forEach (<anonymous>)

Then I did investigating and saw discord_channel = discord_client.channels.findAll("id", DISCORD_CHANNELID)[0];

I am recommending you do an easy error check to verify the discord channel was found and the correct channel Id was supplied. Otherwise I had no idea why discord -> slack worked but not slack -> discord.

Thanks!

events.js:184 Unhandled 'error' event

events.js:184
throw err; // Unhandled 'error' event
^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. (ErrorEvent {
target:
WebSocket {
_events:
[Object: null prototype] {
message: [Function],
open: [Function],
error: [Function],
close: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
readyState: 2,
protocol: '',
_binaryType: 'nodebuffer',
_finalize: [Function: bound finalize],
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_finalized: true,
_closeCode: 1006,
_extensions: {},
_isServer: false,
_receiver:
Receiver {
_binaryType: 'nodebuffer',
_extensions: null,
_maxPayload: 0,
_bufferedBytes: 0,
_buffers: null,
_compressed: false,
_payloadLength: 406,
_fragmented: 0,
_masked: false,
_fin: true,
_mask: null,
_opcode: 1,
_totalPayloadLength: 0,
_messageLength: 0,
_fragments: null,
_cleanupCallback: null,
_isCleaningUp: false,
_hadError: false,
_loop: false,
add: [Function: bound add],
onmessage: null,
onclose: null,
onerror: null,
onping: null,
onpong: null,
_state: 0 },
_sender:
Sender {
_extensions: {},
_socket: [TLSSocket],
_firstFragment: true,
_compress: false,
_bufferedBytes: 0,
_deflating: false,
_queue: [] },
_socket:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'gateway.discord.gg',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 5,
connecting: false,
_hadError: false,
_parent: null,
_host: 'gateway.discord.gg',
_readableState: [ReadableState],
readable: false,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: null,
timeout: 0,
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: 46753,
[Symbol(kHandle)]: null,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBytesRead)]: 813749,
[Symbol(kBytesWritten)]: 17101,
[Symbol(connect-options)]: [Object] },
_error: null,
url: 'wss://gateway.discord.gg/?v=6&encoding=json',
_req: null },
type: 'error',
message: 'read ECONNRESET',
error:
{ Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:167:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' } })
at Client.emit (events.js:182:17)
at WebSocketConnection.onError (/home/pi/SlackDiscordBridges/itemboerse/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
at WebSocket.onError (/home/pi/SlackDiscordBridges/itemboerse/node_modules/ws/lib/event-target.js:128:16)
at WebSocket.emit (events.js:193:13)
at _receiver.cleanup (/home/pi/SlackDiscordBridges/itemboerse/node_modules/ws/lib/websocket.js:211:14)
at Receiver.cleanup (/home/pi/SlackDiscordBridges/itemboerse/node_modules/ws/lib/receiver.js:557:13)
at WebSocket.finalize (/home/pi/SlackDiscordBridges/itemboerse/node_modules/ws/lib/websocket.js:206:20)
at TLSSocket.emit (events.js:193:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node discord2slack.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.