Git Product home page Git Product logo

get-got / discord-downloader-go Goto Github PK

View Code? Open in Web Editor NEW
252.0 10.0 28.0 1.02 MB

A Discord bot program to download and otherwise handle files sent in Discord channels with extensive configuration. Can be used as a genuine Discord Bot or user account / self-bot

License: MIT License

Go 99.80% Dockerfile 0.20%
golang discord downloader discordgo bot utility discord-bot discordapp go download

discord-downloader-go's People

Contributors

get-got avatar twinki14 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar

discord-downloader-go's Issues

Failed to parse settings file.

Failed to parse settings file... json: cannot unmarshal array into Go struct field configuration.credentials of type main.configurationCredentials

	"channels": 
	[
		{
			"channel": "839876059575091270",
			"destination": "C:\\Users\\zyska\\Desktop\\Discord Bot",
			"enabled": true,
			"allowCommands": true,
			"errorMessages": true,
			"scanEdits": true,
			"ignoreBots": false,
			"updatePresence": true,
			"reactWhenDownloaded": true,
			"divideFoldersByType": true,
			"saveImages": true,
			"saveVideos": true
		}
	]

Bit of a mystery when it comes to building the package.

I came to this package via the original github.com/Seklfreak/discord-image-downloader-go package, but because I fancied a more actively maintained project and also JSON config files, I went with yours!

Something, I've noticed with both the original package and yours is that neither seems to build from the command-line using go 1.15.5 under macOS 10.14.6. Both bring up module/version errors. Yours gives...

go: github.com/Necroforger/dgrouter/examples/soundboard imports
	github.com/rylio/ytdl: github.com/rylio/[email protected]: parsing go.mod:
	module declares its path as: github.com/Andreychik32/ytdl
	        but was required as: github.com/rylio/ytdl

This is after the command go build ... which, to my understanding, should build everything in the folder.

Yet, if I load main.go within VS Code, and choose Go: Build Workspace from the command palette, everything builds nicely.

So, it's not a problem! I can work with the package, and indeed I have already forked it, since I plan to make some changes for my specific task. I just thought it was a strange situation. I've already posted messages on https://forum.golangbridge.org and on Twitter, so we'll see if someone can solve this mystery...

account mentioned sender when downloading history

Step 1: run download history
Step 2: ask someone to send a picture
Step 3: the account used to download will mentions the sender.

Why i am issued this? I've trying to downloading the channel history inside a big server and I don't noticed that until someone said I am mass-pinging any picture sender during download process.

The question is how I can disable this?

Docker Container Updates

Any plans to update the docker container? It appears to still be running 1.6.2, last updated 9 months ago.

Issue with file names

I am using this to download a specific file type (its a text file with parameters) that isn't really accounted for, although it refuses to save the file name; "Date InvalidName.asm" Is there a way to get it to correctly grab the name?

Edit; I checked the original program and the same exact thing was happening. It seems to be a MIME mismatch. I am not sure how to get this file type to properly download though, any help would be appreciated.

How to add multiple channels?

I know this is kinda dumb question. I would like to download for example images from 5 chanels and won't open bot 5 times and 5 times edit settings file. Is there way to add this 5 channels 1 time and download it all by 1 command? I tried using ";" or "," between channels ID (in settings file). I couldn't find anything about it in TUT.

Won't download from specific channel/server

So the downloader works great, but only for some servers, I have a server where images are constantly being posted and no matter what the bot won't detect or save the images.. I have the channel in settings and have even tried adding the entire server but it didn't work. I have attached the settings.
(I dont know why it appears deformed.)
"servers": [ { "server": "270613445177638922", "destination": "/home/awildfrog/Share/memeverity/", "divideFoldersByChannel": true } ], "channels": [ { "channel": "680928395399266314", "destination": "/home/awildfrog/Share/memeverity/", "overwriteAllowSkipping": false, "saveImages": true, "saveVideos": true, "saveAudioFiles": true, "saveTextFiles": false, "saveOtherFiles": false },

Segmentation fault on certain invalid URLs

Certain messages with invalid URLs result in a segmentation fault:

Example message to reproduce:
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Logs:

2021/01/24 22:18:02.242994 handlers.go:69: Message [105609928126824448/374491861823520769/105608094721028096]: RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
2021/01/24 22:18:02.248536 handlers.go:105: > FILE: https://%{HTTP_HOST}%{REQUEST_URI}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0xa55d57]
goroutine 4934 [running]:
main.tryDownload(0xc000606013, 0x22, 0x0, 0x0, 0xc00007ced0, 0x2b, 0xc0001231e0, 0x9d5b340, 0xed79fe91a, 0x10ceb20, ...)
	/discord-downloader-go/downloads.go:461 +0x4f7
main.startDownload(0xc000606013, 0x22, 0x0, 0x0, 0xc00007c9f0, 0x2a, 0xc0001231e0, 0x9d5b340, 0xed79fe91a, 0x10ceb20, ...)
	/discord-downloader-go/downloads.go:390 +0x195
main.handleMessage(0xc0001231e0, 0xc000704200)
	/discord-downloader-go/handlers.go:107 +0x5dd
main.messageCreate(0xc00010e240, 0xc00000ebb0)
	/discord-downloader-go/handlers.go:31 +0x33
github.com/bwmarrin/discordgo.messageCreateEventHandler.Handle(0xc3aae0, 0xc00010e240, 0xb30700, 0xc00000ebb0)
	/go/pkg/mod/github.com/bwmarrin/[email protected]/eventhandlers.go:497 +0x4b
created by github.com/bwmarrin/discordgo.(*Session).handle
	/go/pkg/mod/github.com/bwmarrin/[email protected]/event.go:171 +0x111

Running on Docker (custom alpine-based image) but most likely reproducible in all other environments too.

This happens on both newly posted messages as well as when downloading history (history download will not be able to go past that message unless it is deleted).

Trying to Download History of Channel

So i have everything working, but, the history command doesn't work, hell none of them do. I created a "Bot User" so I don't think they come with prefix commands or if they do I don't know what the default one is. I've tried !history and nothing. Also the command is supposed to be typed in the channel I want the history from right? And yes, I know the channel needs to be one that's added to my settings.json.

Any assistance would be greatly appreciated.

Edit: Can Close this! I figured it out. The Prefix is ddg. I was forgetting to add a space after ddg. Derp!

Discord login failed: websocket: close 4004: Authentication failed.

Hi there,

I've used the same Discord token that works with Seklfreak's version and I'm getting the following error:
Discord login failed: websocket: close 4004: Authentication failed.

I use 2FA and take the token from the following location as always:
https://www.youtube.com/watch?v=YEgFvgg7ZPI

I've tried signing out and in to get new tokens, but get the same result.

My settings.json file are the following:
{
"credentials": {
"token": "mfa.blablablablablablablablablablablablablablablablablablablablabla",
"twitterAccessToken": "your access token",
"twitterAccessTokenSecret": "your access token secret",
"twitterConsumerKey": "your consumer key",
"twitterConsumerSecret": "your consumer secret",
"flickrApiKey": "your flickr api key"
},
"admins": [
"4668464563153153"
],
"adminChannels": [
{
"channel": "7896542571245687"
}
],
"debugOutput": false,
"messageOutput": false,
"commandPrefix": "ddg ",
"allowSkipping": true,
"scanOwnMessages": false,
"downloadRetryMax": 5,
"downloadTimeout": 60,
"githubUpdateChecking": true,
"presenceEnabled": true,
"presenceStatus": "online",
"presenceType": 3,
"reactWhenDownloaded": true,
"servers": null,
"channels": [
{
"channel": "245230842401440489",
"destination": "K:\Downloaders\Discord\images"
},
]
}
7

parse error ("destination" folder)

I'm trying to get every image and video shared to me by my fiancée, from the very beginning
is there a discord server where i might be able to get help from more quickly?

I'm getting an error if i put a location into the settings ⇓
image

it seems to be expecting something else:

Error: Parse error on line 25:
...,			"destination": "Y:\Discord Stuff\In
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
,
	"channels": [
		{
			"channel": "135133384786575361",
			"destination": "Y:\Discord Stuff\Inbound",
			"enabled": true,
			"allowCommands": true,
			"errorMessages": true,
			"scanEdits": true,
			"updatePresence": true,
			"reactWhenDownloaded": false,
			"divideFoldersByType": true,
			"saveImages": true,
			"saveVideos": true
		}
	]

Bot can't respond to private channels in 1.3.7

In last version 1.3.7 bot can't respond to private message channel (direct message to bot user):

2020/12/20 16:16:43.950019 discord.go:245: Failed to check permissions (2048) for 412985156786192384: HTTP 404 Not Found, {"message": "404: Not Found", "code": 0}
2020/12/20 16:16:43.959016 commands.go:94: [dgrouter:help] Bot does not have permission to send messages in 412985156786192384

It fails to send message and also fails to do the command (history, help, etc)

1.3.6 is working properly
The channel is in adminChannels

Bot refuses to create config file

Hey! Sorry for more things to deal with, the bot seems to fail during the creation of the config file on initial launch. Maybe I'm doing things wrong? Attached is a screenshot of what it tells me
image

Crashing after downloading 100 files

Trying to grab some backups of some large channels I use for saving images. However, the program seems to crash after downloading 100 files. Doesn't matter where I call the command from, once I have 100 files for that channel downloaded, the application crashes whenever I try to grab anymore.

Is there any more information I can add to this issue that you might need?

Feature request

Hi,

Really enjoying the program this far, works without issues but something I though of that would be useful is the ability to forward instead of downloading media to another discord server/channel, we all have limited space on our PC's and keeping content on a discord server would solve that issue and it might not be that difficult (please correct me if I'm wrong), only issue is that I unfortunately don't understand any of the coding :(

selbot download history possible?

Is there a way to download history via selfbot?
I know about the bot commands, but can't figure out how this would work with selfbot

Twitter API keys

Not sure if i'm doing something wrong, but for some odd reason the program doesn't want to apply the correct keys.

I've triple checked my syntax with a validator, refreshed keys 2 times, rebooted the program many times.
looking up the images, all twitter accounts and posts are still up and valid.

GIF & Video file type support

At the current state of the bot, it gives error messages when it encounters GIFs and Video file types like MP4.

[tryDownload] Could not read response from "https://cdn.discordapp.com/attachments/####/####/file.mp4": context deadline exceeded (Client.Timeout or context cancellation while reading body)

I think having the ability to download these types of media can give more power to the bot.

Bot info:

  • running on self bot mode
  • discord-downloader-go v1.6.1-dev
  • docker - host macOS

sry if the issue is structured poorly

[Suggestion] Can we get a docker container for this?

i've been using this image downloader to backup chats in my discord server but it's a bit of a pain having to keep an instance of windows running just for this to run on. Would it be possible for you to make a docker image to do the same thing?

Self-Bot doesn't work

I set up the Self-Bot, and typed in a commend. The exe said there was a DM from me to the self bot, but no images were downloaded.

Wacky permissions on new folders

I tried using this tool on linux and noticed a problem with the permissions on new folders: d-wxrw---x This means that the owner of the folder can't even read it.

The relevant line is:

err := os.MkdirAll(path, 755)

That 755 should be 0755 as it's supposed to be an octal value.

Thanks for working on this project! It saves me so much time.

"x509: certificate signed by unknown authority" when bot encounters a funimation url

Someone in my server posted this link https://www.funimation.com/shows/fatestay-night-unlimited-blade-works/ and the bot responded with this message

`Download Failure
Gave up trying to download
https://www.funimation.com/shows/fatestay-night-unlimited-blade-works/
after 3 failed attempts...

Download Failed - Error Downloading URL Response
ERROR: Get "https://www.funimation.com/shows/fatestay-night-unlimited-blade-works/": x509: certificate signed by unknown authority

discord-downloader-go v1.4.2-a — discordgo v0.22.0`

I'm running the bot in a docker container and it only seems to have this issue with funimation links

Rate Limit

user got banned for rate limit,

can we add a rate limit to the crawling ?

New feature idea -- AdministratorPower

i added to my version, if you wanna check it i can send codes and its perfectly fine right now.

If some guild user got administrator power, they can use commands but if you do "AdministratorPower = false", they cant.
resim_2022-05-29_012512891
Check it please, maybe you can like it.

Location for log files

I am trying to make a display for my raspberry pi, running this software to show basic info, where are the files containing this. I am mostly looking for number of files downloaded.

Failed to save new settings file...

2021/08/03 22:09:45 config.go:644: [Setup] Failed to save new settings file... open : The system cannot find the file specified.

Not sure what I'm missing.

go runtime error

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x1421d10]

goroutine 43 [running]:
main.handleMessage(0xc000460580, 0x0, 0x0)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/handlers.go:47 +0xd0
main.messageCreate(0xc000128240, 0xc000006b10)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/handlers.go:31 +0x3c
github.com/bwmarrin/discordgo.messageCreateEventHandler.Handle(0x1614da0, 0xc000128240, 0x14fd780, 0xc000006b10)
/home/travis/gopath/pkg/mod/github.com/bwmarrin/[email protected]/eventhandlers.go:497 +0x52
created by github.com/bwmarrin/discordgo.(*Session).handle
/home/travis/gopath/pkg/mod/github.com/bwmarrin/[email protected]/event.go:171 +0x118

Feature request - "Image comparison log?"

Don't know if this already exists in some way and I have simply missed it. But when having the program sort out duplicates it gives the score, and what seams to be a link the the file it is comparing but not the file it is being compared too. Would it be possible to have this displayed? If so I would find it exceptionally useful.

Also could this information be putout to a specific log so that one could manually compare images.

[v1.6.3; Early 2022] Video Setup Tutorial -- some things have changed but this is still accurate enough

I'm Sorry dev but this is not an actual issue but more for the people who got trouble installing it. Here is a video that should help with installing it. If you still can't get it right feel free to contact me for support and i will help you set it up. Dear dev thank you for this tool and it would be awesome if you could pin this "issue" so that the people can find it easier :)

Their Discord Server for help: Discord Invite
My Video: Go to the Video
My discord ID: Jamos#2208

Files disappearing if deleted on discord

I'm not sure if it's a setting I have missed, but after the bot has downloaded an image or video, if the message is then deleted in discord it deleted it from the files for some reason. Is this a bug or is there a way to turn it off?

New Error

major error test

I've been running into this issue recently when I try to scrape any channel, regardless of the account, server, channel or person I've messaged. I've also tried re-downloading the program & resetting my settings from scratch... Any advice on a work around, or what I should do?

Command that triggered the error: "ddg history all"
(I own the server I'm trying to scrape, and I've made sure both Admin Channel & Channel were filled accordingly and properly.)

Updating to discordgo v0.23.1 / Discord API v8

I'm leaving this as a reminder for myself to check on in the future as well as anyone else who is curious why the project is still using v0.22.0+v6

I attempted to update the project to accommodate discordgo v0.23.1 (and thus Discord's API v8), but there are some incompatibility issues, particularly in regards to using a userbot/selfbot with this program.

  • Presence Detail+State was removed from discordgo, the only presence option would be the main status.
  • Presence type "Watching" was removed from discordgo.
  • Intents are now required and this may cause issue with user logins.

It's most likely fine to continue using discordgo v0.22.0 (Discord API v6) as I don't think they'll deprecate it in the near future, but ideally I would like to have the bot use the latest supported versions, so will be keeping an eye on this.

Randomly pings people

The program pings a random person at random intervals, in a specific channel I have it set to. I have it set to download from multiple channels and yet it picks the same one to ping in every time, it isn't even the channel I'm in that it pings, either. it doesn't even seem like it's picking a person who's online. Another weird thing is that spam pings the same person if i use the ctrl+c to close hotkey, and it won't even close itself out. Nothing seems to stop it from pinging people except using task manager or pressing the "X" button.

Downloader crash on using ddg history

I run this application as root. All features worked fine before the latest release.

Steps to reproduce:
type ddg history in the monitored channel

error log:
`panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0xa83cdd]

goroutine 80 [running]:
main.isLocalAdmin(0xc000139a20, 0x11)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/discord.go:283 +0x19d
main.handleCommands.func6(0xc00007a320)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/commands.go:256 +0x1c9a
github.com/Necroforger/dgrouter/exrouter.WrapHandler.func1(0xbcf4e0, 0xc00007a320)
/home/travis/gopath/pkg/mod/github.com/!necroforger/[email protected]/exrouter/router_wrapper.go:128 +0x42
github.com/Necroforger/dgrouter/exrouter.(*Route).FindAndExecute(0xc00050e508, 0xc000f52240, 0xc0002be8f8, 0x4, 0xc00050b2c0, 0x12, 0xc000139a20, 0x0, 0x0)
/home/travis/gopath/pkg/mod/github.com/!necroforger/[email protected]/exrouter/router_wrapper.go:114 +0x622
main.handleMessage(0xc000fc7b80, 0x0, 0x0)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/handlers.go:67 +0x104e
main.messageCreate(0xc000f52240, 0xc00050e8b0)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/handlers.go:31 +0x35
github.com/bwmarrin/discordgo.messageCreateEventHandler.Handle(0xc851f8, 0xc000f52240, 0xb6d620, 0xc00050e8b0)
/home/travis/gopath/pkg/mod/github.com/bwmarrin/[email protected]/eventhandlers.go:497 +0x4b
created by github.com/bwmarrin/discordgo.(*Session).handle
/home/travis/gopath/pkg/mod/github.com/bwmarrin/[email protected]/event.go:171 +0x111`

Authentication error

Config setup is fine, just when I try to launch it I get this error:

2021/05/13 14:14:35.864932 main.go:347: Discord login failed: websocket: close 4004: Authentication failed.
2021/05/13 14:14:35.867897 common.go:29: Exiting in 15 seconds - uptime was 921 milliseconds 161 microseconds ...

suggestion

can you add a percent while downloading 10% 80% 100%
and fix videos downloading the app working well with downloading pictures i downloaded 40k picture all fine
but Videos from 40k video only 41 video downloaded
Please fix downloading videos issue
and make button to skip like hitting ENTER Skip the video it stuck on i been stuck on downloading a MP4 0:06 long
for 2 hours i have screenshot .-. like i'm mad bit but it is working atlest
and can you add this as feature when we turn off the program and start it up again and it will download same image downloaded can you add feature that SKIPS everything already downloaded?

Guide: Downloading History (Old Messages)

hello im trying to download all the videos from a specific channel even ones sent in the past and im not really sure how to combine the two snippets of code you provided. i tried following the old messaged tutorial you wrote but i kept getting confused.
this is what my settings file looks like without the information filled in:

{
"credentials": {
"email": "REPLACE_WITH_YOUR_EMAIL",
"password": "REPLACE_WITH_YOUR_PASSWORD"
},
"scanOwnMessages": true,
"presenceEnabled": false,
"channels": [
{
"channel": "DISCORD_CHANNEL_ID_TO_DOWNLOAD_FROM",
"destination": "FOLDER_LOCATION_TO_DOWNLOAD_TO",
"allowCommands": false,
"errorMessages": false,
"reactWhenDownloaded": false
}
]
}

but im not sure how to place this snippet of code you provided into it to download all the other messages;
ddg history 000111000111000 --since=2020-01-02

Bot randomly reacts to messages with emojis

so the bot just started to react to messages with emojis and got me banned because the server thought that i was trolling.
i dont know if this can be disabled or what but i think its a problem.

i didnt had that problem before. i downloaded the newest version and ran for 3-4 hours with no porblem.
and when i started again this morning its started to react to messages.i dont know why. everything is the same in the setting
maybe its only for me but if not, i think it should be fixed

Bot gets stuck in error loop if computer goes to sleep

If a computer running the downloader goes into sleep mode for a while and is then woken up the bot just logs this message every few seconds

2021/01/27 11:04:22.684872 logging.go:63: [DG0] wsapi.go:302:heartbeat() error sending heartbeat to gateway wss://gateway.discord.gg/?v=6&encoding=json, websocket: close sent

this issue also effects a docker container if it is paused and then unpaused after a while. Easiest way to replicate is to start the bot in a container, pause it, wait 10 minutes and unpause the container

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.