This tool enables you to import messages from a specific Slack channel and post them to a designated Discord channel. The importer supports messages, threads, files (images, documents), and emojis, ensuring a seamless migration. Note: The script imports messages from the last 24 hours relative to the time it is executed. To avoid duplicate imports, it is recommended to schedule the script to run once per day (e.g., using crontab
). Parameterizing this behavior is a potential enhancement.
- Import Slack messages to Discord, including threads.
- Transfer files (images, documents, etc.).
- Preserve emojis in messages.
- Imports messages from the last 24 hours relative to execution time.
- Add support for importing reactions.
- Parameterize the time range for imports (e.g., set specific hours or custom durations).
- Python 3.8+
discord.py==2.0.0
slack-sdk==3.19.6
requests==2.28.1
python-dotenv==0.21.0
-
Clone this repository:
git clone https://github.com/yourusername/slack-to-discord-importer.git cd slack-to-discord-importer
-
Install the required dependencies:
pip3 install -r requirements.txt
-
Create a
.env
file with the following environment variables:SLACK_API_TOKEN=slack_token SLACK_CHANNEL_ID="slack channel id in string" DISCORD_BOT_TOKEN=discord_bot_token DISCORD_CHANNEL_ID=discord_channel_id_in_integer
-
Run the script:
python3 script_name.py
To function correctly, the Slack bot requires the following OAuth scopes:
OAuth Scope | Description |
---|---|
channels:history |
View messages and other content in public channels that slack2discord has been added to |
channels:read |
View basic information about public channels in a workspace |
files:read |
View files shared in channels and conversations that slack2discord has been added to |
groups:read |
View basic information about private channels that slack2discord has been added to |
metadata.message:read |
Allows slack2discord to read message metadata in channels that slack2discord has been added to |
users:read |
View people in a workspace |
users.profile:read |
View profile details about people in a workspace |
The Discord bot must have these permissions for the designated channel:
View Channel
Send Messages
Attach Files
Manage Threads
Create Public Threads
Send Messages in Threads
Before running the script, ensure the following steps are completed:
- Add the Slack bot to your Slack workspace and the desired channel.
- Add the Discord bot to your Discord server with the required permissions.
- Obtain the Slack channel ID by navigating to the desired channel in Slack, clicking the channel name, and copying the
Channel ID
from the settings or URL. - Obtain the Discord channel ID by enabling Developer Mode in Discord settings, right-clicking the desired channel, and selecting "Copy ID."
- Ensure the bot is added to both Slack and Discord with the necessary permissions.
- Modify the
.env
file to specify the Slack channel and Discord channel to be synced. - Schedule the script to run once per day to avoid duplicate imports. For example, using
crontab
:0 0 * * * /usr/bin/python3 /path/to/script.py
The script generates a debug.log
file to help monitor activities and debug any issues.