Giter VIP home page Giter VIP logo

Comments (8)

ChargeDog avatar ChargeDog commented on August 16, 2024 1

Ah that's it - yep, it doesn't have the send message permission. Added it to the bot and now it works fine.

from discord-downloader-go.

get-got avatar get-got commented on August 16, 2024

@Seraphim2150 I'm testing it myself right now and I'll get back to you if I figure it out.

In the meantime, it could help to run it within command prompt (open command prompt within the folder it's in and type "filename.exe", that way when it crashes you can see what the error is.)

EDIT: My test surpassed 900 messages without issue, so it's possible it's related to the permissions your bot has. I can't really fix if I can't replicate, unless you can figure out what the error it's throwing is. Running within command prompt should make it easy to troubleshoot, since it won't close the window when the program crashes, so you can see what error it's throwing.

from discord-downloader-go.

ChargeDog avatar ChargeDog commented on August 16, 2024

Hi ran a test using powershell, having already got 100 images downloaded.

The error before the crash is thrown is
HTTP 403 Forbidden, {"message": "Missing Permissions", "code": 50013}

This then leads to a panic: runtime error: invalid memory address or nil pointer dereference

I guess this is a permissions issue. Need to double check which ones are the issue - but glad to hear it supports 900 messages!

EDIT: Updated the bot with Admin permissions, it now works fine. Will try and tweak it to see which combo works best.

from discord-downloader-go.

get-got avatar get-got commented on August 16, 2024

@Seraphim2150 Does it say the line number the exception is occurring on? Could help me pinpoint which request is needing permissions.

All that the history handler requests during fetching of more messages is that action itself (requesting more messages) and editing the status message.

I don't think there's a permission that restricts message editing (unless the channel has slowmode enabled?), so the only other thing I can think of is the Read Message History permission, that could be preventing it from requesting more messages.

from discord-downloader-go.

ChargeDog avatar ChargeDog commented on August 16, 2024

Here is the complete stack when it fails. Started from scratch (removed downloaded files and catalogue) - the bot had the permissions "Read text channels & see voice channels" and "Read Message History". Channel does not have slow mode enabled.

2020/11/24 02:41:22.854264 handlers.go:157: [handleHistory] Requesting 100 more messages, 100 cataloged, (before 2020-08-28 04:19:48.443 +0000 +0000)
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0xb08173]

goroutine 82 [running]:
main.handleHistory(0xc0004ea9a0, 0xc0005f5900, 0x12, 0xc0005f59c7, 0x12, 0x0)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/handlers.go:165 +0x1a53
main.main.func5(0xc000014dc0)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/main.go:377 +0x10d2
github.com/Necroforger/dgrouter/exrouter.WrapHandler.func1(0xc24160, 0xc000014dc0)
/home/travis/gopath/pkg/mod/github.com/!necroforger/[email protected]/exrouter/router_wrapper.go:128 +0x47
github.com/Necroforger/dgrouter/exrouter.(*Route).FindAndExecute(0xc0000062e8, 0xc00011a240, 0xc0002fad48, 0x4, 0xc00001f080, 0x12, 0xc0004ea9a0, 0x0, 0x0)
/home/travis/gopath/pkg/mod/github.com/!necroforger/[email protected]/exrouter/router_wrapper.go:114 +0x631
main.main.func7(0xc00011a240, 0xc0000063d0)
/home/travis/gopath/src/github.com/get-got/discord-downloader-go/main.go:429 +0x15f
github.com/bwmarrin/discordgo.messageCreateEventHandler.Handle(0xc0004e8b70, 0xc00011a240, 0xbcc200, 0xc0000063d0)
/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

from discord-downloader-go.

get-got avatar get-got commented on August 16, 2024

@Seraphim2150 hmm, this is odd, the line it's crashing on seems like it has to do with the editing of the message.

I tried stripping my test bot of all perms except Read Messages, Send Messages, Read History, but mine works fine still.

With your current version, does it send the initial status message? Do commands work? (because I wonder if it has to do with building of embeds).

Try this file below, it's a version I just added some extra outputting to in order to try and find exactly where the crash occurs for you (and disabled embed coloring, in the event that's causing it).
discord-downloader-go.zip

from discord-downloader-go.

ChargeDog avatar ChargeDog commented on August 16, 2024

It reacts to commands and initial status message is sent. It's once I've fired a command (sent from my admin channel) that it crashes.

Updated log below using the file you passed over. Just blanked out some personal stuff. These settings work fine when the bot is full admin, but fail with the permissions I'd set.

2020/11/24 03:10:20.810104 main.go:46: Welcome to discord-downloader-go v1.1.0!
2020/11/24 03:10:20.814093 main.go:47: > discord-go v0.22.0, Discord API v6
2020/11/24 03:10:20.816088 main.go:54: Loading settings from "settings.json"...
2020/11/24 03:10:20.818083 config.go:211: [DebugOutput] Parsed Fixed Settings into JSON:

{
"credentials": {
"token": MY TOKEN,
"email": "REPLACE_WITH_YOUR_EMAIL_OR_DELETE_LINE",
"password": "REPLACE_WITH_YOUR_PASSWORD_OR_DELETE_LINE"
},
"admins": [
"MY ADMIN"
],
"downloadRetryMax": 3,
"downloadTimeout": 60,
"commandPrefix": "ddg_",
"allowSkipping": true,
"scanOwnMessages": true,
"presenceEnabled": true,
"presenceStatus": "idle",
"filenameDateFormat": "2006-01-02_15-04-05 ",
"githubUpdateChecking": true,
"debugOutput": true,
"inflateCount": 0,
"adminChannels": [
{
"channel": "780394960179560448"
}
],
"channels": [
{
"channel": "MY_CHANNEL",
"destination": "Superhero_notes",
"enabled": true,
"allowCommands": true,
"errorMessages": true,
"scanEdits": true,
"updatePresence": true,
"reactWhenDownloaded": true,
"reactWhenDownloadedEmoji": "",
"blacklistReactEmojis": [],
"divideFoldersByType": false,
"saveImages": true,
"saveVideos": true,
"saveAudioFiles": false,
"saveTextFiles": false,
"saveOtherFiles": false,
"savePossibleDuplicates": true,
"blacklistedExtensions": [
".htm",
".html",
".php",
".exe",
".dll",
".bin",
".cmd",
".sh",
".py",
".jar"
]
},
{
"channel": "MY_OTHER_CHANNEL",
"destination": "world_notes",
"enabled": true,
"allowCommands": true,
"errorMessages": true,
"scanEdits": true,
"updatePresence": true,
"reactWhenDownloaded": true,
"reactWhenDownloadedEmoji": "",
"blacklistReactEmojis": [],
"divideFoldersByType": false,
"saveImages": true,
"saveVideos": true,
"saveAudioFiles": false,
"saveTextFiles": false,
"saveOtherFiles": false,
"savePossibleDuplicates": true,
"blacklistedExtensions": [
".htm",
".html",
".php",
".exe",
".dll",
".bin",
".cmd",
".sh",
".py",
".jar"
]
}
]
}

2020/11/24 03:10:20.888893 main.go:56: Settings loaded, bound to 2 channel(s)
2020/11/24 03:10:21.200693 main.go:67: Opening database...
2020/11/24 03:10:30.861162 main.go:121: Twitter API credentials missing, the bot won't use the Twitter API.
2020/11/24 03:10:30.867146 main.go:156: Connecting to Discord via Token...
2020/11/24 03:10:31.526004 main.go:181: Discord logged into 2020/11/24 03:10:20.888893 main.go:56: Settings loaded, bound to 2 channel(s)
2020/11/24 03:10:21.200693 main.go:67: Opening database...
2020/11/24 03:10:30.861162 main.go:121: Twitter API credentials missing, the bot won't use the Twitter API.
2020/11/24 03:10:30.867146 main.go:156: Connecting to Discord via Token...
2020/11/24 03:10:31.526004 main.go:181: Discord logged into BOT_NAME
2020/11/24 03:10:31.529994 main.go:183: [Helper] This is a Bot User...
2020/11/24 03:10:31.531988 main.go:184: [Helper] - Status presence details are limited.
2020/11/24 03:10:31.534981 main.go:185: [Helper] - Server access is restricted to servers you have permission to add the bot to.
2020/11/24 03:10:31.672705 main.go:442: [DebugOutput] Starting background loops...
2020/11/24 03:10:31.676696 main.go:457: [DebugOutput] Startup finished, took 10.8665922s...
2020/11/24 03:10:31.680685 main.go:461: Discord Download Bot is online! Connected to 1 server(s)
2020/11/24 03:10:31.684674 main.go:464: Ctrl+C to exit...
2020/11/24 03:16:21.020176 handlers.go:148: [handleHistory] Failed to send command embed message (requested by MY_USERNAME ): HTTP 403 Forbidden, {"message": "Missing Permissions", "code": 50013}
2020/11/24 03:16:21.026160 handlers.go:150: [handleHistory] MY_USERNAME began cataloging history for MY_CHANNEL
2020/11/24 03:16:21.539662 handlers.go:157: [handleHistory] Requesting 100 more messages, 0 cataloged, (before 2020-08-28 04:19:48.443 +0000 +0000)
2020/11/24 03:16:21.545647 handlers.go:162: Trying to edit status message...
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x8c7b5f]

goroutine 100 [running]:
main.handleHistory(0xc000170f20, 0xc00040b4a0, 0x12, 0xc000061867, 0x12, 0x0)
P:/Projects/Go/src/github.com/get-got/discord-downloader-go/handlers.go:166 +0x1adf
main.main.func5(0xc000100410)
P:/Projects/Go/src/github.com/get-got/discord-downloader-go/main.go:377 +0x10d2
github.com/Necroforger/dgrouter/exrouter.WrapHandler.func1(0x9e4160, 0xc000100410)
P:/Projects/Go/pkg/mod/github.com/!necroforger/[email protected]/exrouter/router_wrapper.go:128 +0x47
github.com/Necroforger/dgrouter/exrouter.(*Route).FindAndExecute(0xc00014a8c0, 0xc00015a240, 0xc0002dccc8, 0x4, 0xc00001ede0, 0x12, 0xc000170f20, 0xb1daa0, 0xc0001050a0)
P:/Projects/Go/pkg/mod/github.com/!necroforger/[email protected]/exrouter/router_wrapper.go:114 +0x631
main.main.func7(0xc00015a240, 0xc00014a2e0)
P:/Projects/Go/src/github.com/get-got/discord-downloader-go/main.go:429 +0x15f
github.com/bwmarrin/discordgo.messageCreateEventHandler.Handle(0xc00007d130, 0xc00015a240, 0x98c200, 0xc00014a2e0)
P:/Projects/Go/pkg/mod/github.com/bwmarrin/[email protected]/eventhandlers.go:497 +0x52
created by github.com/bwmarrin/discordgo.(*Session).handle
P:/Projects/Go/pkg/mod/github.com/bwmarrin/[email protected]/event.go:171 +0x118
2020/11/24 03:10:31.529994 main.go:183: [Helper] This is a Bot User...
2020/11/24 03:10:31.531988 main.go:184: [Helper] - Status presence details are limited.
2020/11/24 03:10:31.534981 main.go:185: [Helper] - Server access is restricted to servers you have permission to add the bot to.
2020/11/24 03:10:31.672705 main.go:442: [DebugOutput] Starting background loops...
2020/11/24 03:10:31.676696 main.go:457: [DebugOutput] Startup finished, took 10.8665922s...
2020/11/24 03:10:31.680685 main.go:461: Discord Download Bot is online! Connected to 1 server(s)
2020/11/24 03:10:31.684674 main.go:464: Ctrl+C to exit...
2020/11/24 03:16:21.020176 handlers.go:148: [handleHistory] Failed to send command embed message (requested by "ChargeDog"#2895): HTTP 403 Forbidden, {"message": "Missing Permissions", "code": 50013}
2020/11/24 03:16:21.026160 handlers.go:150: [handleHistory] "ChargeDog"#2895 began cataloging history for 653938880084443150
2020/11/24 03:16:21.539662 handlers.go:157: [handleHistory] Requesting 100 more messages, 0 cataloged, (before 2020-08-28 04:19:48.443 +0000 +0000)
2020/11/24 03:16:21.545647 handlers.go:162: Trying to edit status message...
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x8c7b5f]

goroutine 100 [running]:
main.handleHistory(0xc000170f20, 0xc00040b4a0, 0x12, 0xc000061867, 0x12, 0x0)
P:/Projects/Go/src/github.com/get-got/discord-downloader-go/handlers.go:166 +0x1adf
main.main.func5(0xc000100410)
P:/Projects/Go/src/github.com/get-got/discord-downloader-go/main.go:377 +0x10d2
github.com/Necroforger/dgrouter/exrouter.WrapHandler.func1(0x9e4160, 0xc000100410)
P:/Projects/Go/pkg/mod/github.com/!necroforger/[email protected]/exrouter/router_wrapper.go:128 +0x47
github.com/Necroforger/dgrouter/exrouter.(*Route).FindAndExecute(0xc00014a8c0, 0xc00015a240, 0xc0002dccc8, 0x4, 0xc00001ede0, 0x12, 0xc000170f20, 0xb1daa0, 0xc0001050a0)
P:/Projects/Go/pkg/mod/github.com/!necroforger/[email protected]/exrouter/router_wrapper.go:114 +0x631
main.main.func7(0xc00015a240, 0xc00014a2e0)
P:/Projects/Go/src/github.com/get-got/discord-downloader-go/main.go:429 +0x15f
github.com/bwmarrin/discordgo.messageCreateEventHandler.Handle(0xc00007d130, 0xc00015a240, 0x98c200, 0xc00014a2e0)
P:/Projects/Go/pkg/mod/github.com/bwmarrin/[email protected]/eventhandlers.go:497 +0x52
created by github.com/bwmarrin/discordgo.(*Session).handle
P:/Projects/Go/pkg/mod/github.com/bwmarrin/[email protected]/event.go:171 +0x118

from discord-downloader-go.

get-got avatar get-got commented on August 16, 2024

@Seraphim2150 I see the permission issue now. It's crashing because it's trying to edit a message that doesn't exist. When using that command, it outputs in the log but also sends a message in Discord, so if the bot doesn't have the Send Messages permission, (with how it's currently setup) it will crash if it can't properly manage the status messages.

2020/11/24 03:16:21.020176 handlers.go:148: [handleHistory] Failed to send command embed message (requested by MY_USERNAME ): HTTP 403 Forbidden, {"message": "Missing Permissions", "code": 50013} then promptly crashes when trying to update the message it never sent: 2020/11/24 03:16:21.545647 handlers.go:162: Trying to edit status message... panic: runtime error: invalid memory address or nil pointer dereference

Does the bot have Send Messages permissions for the channel(s)? That would be the problem, if not. Next update I'll implement checks for the message to prevent crashing in case anyone else has permissions issues like this.

EDIT: If you're using the command via an admin channel, it needs to have Send Message permissions in that channel too, as that's where it'll send status messages.

from discord-downloader-go.

Related Issues (20)

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.