Skip to content

Section Discord (basic)

Qais Patankar edited this page Mar 6, 2020 · 21 revisions

Basic example

[discord.mydiscord]

# You can get your token by following the instructions on
# https://github.com/42wim/matterbridge/wiki/Discord-bot-setup
# If you want roles/groups mentions to be shown with names instead of ID, 
# you'll need to give your bot the "Manage Roles" permission.
Token="YOUR_TOKEN_HERE"

Server="name or uid of guild" # picked from guilds the bot is connected to

RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

Full list

Entire set of options that can be used in a Discord gateway
[discord]

[discord.game]
# Token (REQUIRED) is the token to connect with Discord API
# You can get your token by following the instructions on 
# https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token
# If you want roles/groups mentions to be shown with names instead of ID, you'll need to give your bot the "Manage Roles" permission.
Token="Yourtokenhere"

# Server is the ID or name of the guild to connect to, selected from the guilds the bot has been invited to
Server="yourservername"

## RELOADABLE SETTINGS
## Settings below can be reloaded by editing the file

# ShowEmbeds shows the title, description and URL of embedded messages (sent by other bots)
ShowEmbeds=false

# UseUserName shows the username instead of the server nickname
UseUserName=false

# UseDiscriminator appends the `#xxxx` discriminator when used with UseUserName
UseDiscriminator=false

# WebhookURL, if specified, will send messages in the style of puppets.
# This only works if you have one discord channel, if you have multiple discord channels you'll have to specify it in the gateway config
# Example: "https://discordapp.com/api/webhooks/1234/abcd_xyzw"
WebhookURL=""

# EditDisable allows you to disable sending of edits to other bridges
EditDisable=false

# EditSuffix specifies the message to be appended to every edited message
# Example: " (edited)"
EditSuffix=""

# IgnoreNicks allows you to mute outgoing messages from certain users.
# Messages from these users will not be transmitted to other bridges.
# Regular expressions are also supported.
# Example: "ircspammer1 ircspammer2"
IgnoreNicks=""

# IgnoreMessages allows you to mute outgoing messages of a certain format.
# Messages matching this regular expression will not be transmitted sent to other bridges
# See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#
# Example that ignores messages starting with ~~ or messages containing badword:
#   IgnoreMessages="^~~ badword"
IgnoreMessages=""

# ReplaceMessages replaces substrings of messages in outgoing messages.
# Regular expressions are supported.
#
# Example that replaces 'cat' => 'dog' and 'sleep' => 'awake':
#   ReplaceMessages=[ ["cat","dog"], ["sleep","awake"] ]
# Example that replaces all digits with the letter 'X', so 'hello123' becomes 'helloXXX':
#   ReplaceMessages=[ ["[0-9]","X"] ]
ReplaceMessages=[]

# ReplaceNicks replaces substrings of usernames in outgoing messages.
# See the ReplaceMessages setting for examples.
# Example: [ ["user--","user"] ]
ReplaceNicks=[]

# ExtractNicks allows for interoperability with other bridge software by rewriting messages and extracting usernames.
#
# Recommended reading:
# - https://github.com/42wim/matterbridge/issues/466
# - https://github.com/42wim/matterbridge/issues/713
#
# This example translates the following message
#   "Relaybot: <relayeduser> something interesting"
# into this message
#   "relayeduser: something interesting"
# like so:
#   ExtractNicks=[ [ "Relaybot", "<(.*?)>\\s+" ] ]
#
# This example translates the following message
#   "otherbot: (relayeduser) something else"
# into this message
#   "relayeduser: something else"
# like so:
#   ExtractNicks=[ [ "otherbot","\\((.*?)\\)\\s+" ] ]
#
# This example combines both of the above examples into one:
#   ExtractNicks=[ [ "Relaybot", "<(.*?)>\\s+" ],[ "otherbot","\\((.*?)\\)\\s+" ]
#
ExtractNicks=[]

# Label can be used as an extra identifier for use in the RemoteNickFormat setting.
Label=""

# RemoteNickFormat specifies how remote users appear on this bridge.
# See the [general] config section for default options
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

# ShowJoinPart will emit messages that show joins/parts from other bridges
# Supported from the following bridges: irc, mattermost, slack, discord
ShowJoinPart=false

# StripNick will strip non-alphanumeric characters from nicknames.
# Recommended reading: https://github.com/42wim/matterbridge/issues/285
StripNick=false

# ShowTopicChange will emit messages that show topic/purpose updates from other bridges
# Supported from the following bridges: slack
ShowTopicChange=false

# SyncTopic will sync topic/purpose updates from other bridges
# Supported from the following bridges: slack
SyncTopic=false

Username/avatar spoofing

Creating a message via a user's API token (the basic configuration above) only lets Matterbridge post with the user/avatar that generated the token. But executing a webhook can set any old username and avatar URL.

Discord webhooks are per-channel. We can implement webhook creation and/or editing but this isn't done yet (see #674). Until then, you'll need to create a webhook for each channel that you want to synchronize:

  1. On Discord, go to Server Settings, then Webhooks
  2. Specify the name and channel, and copy the resulting webhook URL
  3. Paste in your gateway as WebhookURL="https://discordapp.com/api/webhooks/529689699999999999/Da-H4RRY_P0-kjdsknkfgfjghf

The resulting gateway configuration should look like this (for now, you'll need a gateway for each channel that works this way):

[[gateway]]
name="testing"
enable=true
[[gateway.inout]]
account="slack.myworkspace"
channel="testing"
[[gateway.inout]]
account="discord.myserver"
channel="testing"
[gateway.inout.options]
WebhookURL="https://discordapp.com/api/webhooks/thing1/thing2"

User token

To use a user token instead of a bot, refer to the settings page

Clone this wiki locally