A Discord bot for downloading attachments from channel messages.

dcdl

This is a Discord bot for downloading attachments from channel messages.

Setup

First, set up a Discord bot application (see here how to do so).

Now, you can go to OAuth2 in the Discord bot application page and go to the sub route URL Generator. There, select the scopes bot and applications.commands. Now, you can copy the Generated Url and pate it into your browser. You might now log in to Discord. After that, select the server you want to have the bot on and invite it.

Using Docker

You can use the provided docker-compose.yml to set up the bot. In the environment configuration, you must set the bot token obtained from the Discord bot application.

You can of course also run the image using the Docker CLI as well.

$ docker run -d \
    --publish "80:80" \
    --name dcdl \
    --env "DCDL_DISCORD_TOKEN=OTEwN..." \
    --env "DCDL_WEBSERVER_PUBLICADDRESS=https://example.com" \
    ghcr.io/zekrotja/dcdl:latest

Using Precompiled Binaries

You can also download precompiled binaries from the actions pipeline.

Then, simply create a configuration file.

./config.yml

discord:
  token: OTEwN...

webserver:
  publicaddress: https://example.com

storage:
  location: ./data

Following, cerate the data directory.

$ mkdir data

After that, start the bot with the following command line.

$ ./dcdl -c config.yml

Usage

Now, go into a text channel and type /collect. Then, the command should pop up.

image

Here, you can now specify following optional arguments.

  • channel: The target channel. This is set to the current channel if not specified.

  • limit: The maximum amount of messages to be fetched. This defaults to 0 (equals all messages in the channel) or the globally set limit.

  • include-metadata: Whether or not to include a metadata.json in the colelction package containing information about each message containing attachments. This defaults to true.

  • include-files: Whether or not download and include the attachment files. You can set this to false if you want to download the files from your system using the metadata.json file. This defaults to true.

Download via metadata.json

You can also download the attachments on your system using the metadata.json file from the archive using the following command.

Therefore, you need curl and jq installed. If you are on windows, use WSL. 😉

$ mkdir files && cat metadata.json | jq -r '.[].attachments[] | [ .archive_filename, .url ] | join(" ")' | xargs -l bash -c 'curl -Lo "files/$0" "$1"'

You can even do stuff like filter by author ID, for example, using the following command.

$ cat metadata.json | jq -r '.[] | select( .author_id == "221905671296253953" )

... and then combine it with the download command to just download attachments sent by that specific user.

$ mkdir files && cat metadata.json | jq -r '.[] | select( .author_id == "221905671296253953" ) | .attachments[] | [ .archive_filename, .url ] | join(" ")' | xargs -l bash -c 'curl -Lo "files/$0" "$1"'

Man, jq is really one of the most useful CLI tool ever created, inst it? 😄

Owner
Ringo Hoffmann
Full stack developer. SysAdmin and DevOps Enthusiast. I ♥ Go, C#, React and Docker. | he/him
Ringo Hoffmann
Similar Resources

Instagram to Telegram Channel Bot.

InstaTG Instagram to Telegram Channel Bot. Can access posts from any public Instagram account or an account that you follow. Features Keeps track of e

Nov 16, 2022

Simple telegram Bot to ban Anonymous Channel users in a group

Restrict Channel Robot Telegram Bot, written in GoLang to delete messages and ban anonymous users who send as channel in groups. Can be found on teleg

Dec 20, 2022

A telegram bot to ban the chat spammers by channel, made with Golang.

ChannelBot A telegram bot to ban channels spamming chat. Vars TOKEN - Your Telegram Bot Token (@BotFather) More Information With the latest update of

Nov 8, 2022

This slack-bot collects all @gophers notifications into one slack channel

slack-bot Slack bot copying reference to a ping to notifications channel The bot is designed to listen on messages containing specific tag, copy refer

Apr 11, 2022

Bot-template - A simple bot template for creating a bot which includes a config, postgresql database

bot-template This is a simple bot template for creating a bot which includes a c

Sep 9, 2022

Bridge Chrome "native messages" to Discord's IPC socket

chrome-discord-bridge This code bridges Chrome "native messages" to Discord's IPC socket. It's written in Go with no third-party dependencies. It's in

Nov 18, 2022

Golang bot that connects to slack using Socketclient to read and write messages.

Golang bot that connects to slack using Socketclient to read and write messages.

🚀 (not)simple go project 🚀 Golang bot that connects to slack using Socketclient to read and write messages. 🏆 Use 🏆 @SquidBot : Mentions your name

Aug 23, 2022

Discord-dl: a tool to archive discord channels

discord-dl discord-dl is a tool to archive discord channels. I think it's safe t

May 18, 2022

Discord-notif - Send notifications to discord in Your pipelines or scripts

Discord-notif - Send notifications to discord in Your pipelines or scripts

discord-notif Send notifications to discord in Your pipelines or scripts install

Dec 15, 2022
Comments
  • Command Execution Unexpectedly Failed

    Command Execution Unexpectedly Failed

    Hi there,

    I feel as though I'm SO CLOSE to getting this bot to do exactly what I'm looking for, but for some reason it won't execute its commands properly.

    Screen Shot 2022-01-06 at 7 24 37 PM

    I have this docker container running alongside hundreds of other functional and reachable-through-reverse-proxy services, and can't find what's preventing the command from running properly. Below is an image of the environment variables I've set up through the Unraid interface, with all volume mounts showing correctly in the file system:

    Screen Shot 2022-01-06 at 7 27 09 PM

    Any help would be really appreciated!

  • AcceptMsg before large content download

    AcceptMsg before large content download

Related tags
Discord-bot - A Discord bot with golang

JS discord bots Install Clone repo git clone https://github.com/fu-js/discord-bo

Aug 2, 2022
A Discord bot for managing ephemeral roles based upon voice channel member presence.
A Discord bot for managing ephemeral roles based upon voice channel member presence.

ephemeral-roles A Discord bot for managing ephemeral roles based upon voice channel member presence. Quickstart Click on the Ephemeral Roles logo head

Dec 19, 2022
A discord bot that watches for tiktok URL's and automatically uploads the corresponding video to the channel

TikiTok Bot A Discord bot that watches for TikTok URLs and sends a message to the channel with the corresponding video attached Click to invite the bo

Jul 28, 2022
Wipe-discord - TUI application to erase Discord messages
Wipe-discord - TUI application to erase Discord messages

wipe-discord Terminal user interface (TUI) application to delete Discord message

Aug 21, 2022
Slack-emoji-bot - This Slack bot will post the newly created custom Slack emojis to the channel of your choice

Slack Emoji Bot This Slack bot will post the newly created custom Slack emojis t

Oct 21, 2022
Discord bot to find the most liked messages

Emotive Emotive is a discord bot written in Go made for OCM Discord that can tell you the most interesting messages in a channel. These are based on t

Nov 8, 2021
Tg-channel-api - A JSON API for latest messages of public Telegram channels

Telegram Channel API A JSON API for latest messages of public Telegram channels.

Oct 27, 2022
A simple Discord bot developed for the Bedrock Gophers discord server.

Bedrock Gopher A simple Discord bot developed for the Bedrock Gophers discord server. Click here to invite the bot to your guild. You will also need t

Mar 12, 2022
InStockBot notifies a selected Discord channel when a specific product is back in stock

InStockBot notifies a selected Discord channel when a specific product is back in stock

Jan 20, 2022
Feline-bot - Feline Bot for Discord using Golang

Feline Bot for Discord Development This bot is implemented using Golang. Feature

Feb 10, 2022