Seklfreak / discord-image-downloader-go

A simple tool which downloads pictures posted in discord channels of your choice to a local folder.
MIT License
350 stars 90 forks source link

Interactive Channels Not functioning when also set as regular channels #108

Open ghost opened 5 years ago

ghost commented 5 years ago

Hey so i came across an issue, and was trying to figure out what was causing it, so basically i wasn't able to get the interactive channels to work, and i even read through all of the things on the GitHub page, and nothing worked, it was once i manually went through the programs source code that i discovered, if a channel id is set in both the channels and interactive channels things, it will not be recognised as an interactive channel, i believe that at the very least, this should be noted in at-least some documentation since i was unable to find ANY information about that. Like literally all i had to do to fix the issue was to just remove the channel that i wanted interactive from being under the regular channels header. Also btw amazing program.

Ju-221 commented 5 years ago

The problem so far from what I've been able to read from the handleDiscordMessage function is that the funct checks in the interactive channels for commands such as "history" and "help" but the moment it does that it can't check for URLS at the same time. Because of this if you put the interactive channel as the download channel the URL checker will override the handleDiscordMessage function. Another example would be "stats @whateveruserID" wouldn't work but "stats" does as the case switch handler only has the text programmed for it.

A way to fix this would be to implement the URL handler in the handleDiscordMessage function so that as it checks for URLs as it also checks for commands, might as well add a string splitter if someone uses a "stats @user" function. However it must as well check if the config.ini file has the interactive channel the same number as the download channel in order to do this.

A prototype of the new function would be :

func handleDiscordMessage(m *discordgo.Message){

switch {
case message == "help"
                    ...
case message == "version"
                    ...
case message == "stats*" //wildcard calling 
           strings.Split(message, "@")
case <URL> 
        //Maybe every string starting with http* ? or using the xurl function 
          but not sure that'll work in a switch
               ....
}

Hope this can be of any help, will try to program something like this in the future and post the results here if possible but I can't promise it.

Kakkela commented 5 years ago

I think this is somewhat out of scope to fix since the intended way to use it is to have interactive channel as your direct messages to bot instead of normal channel. Even if you want to have regular channel on some server as your interactive channel I don't see why you would want to have it as normal download channel too then. Could you explain in what kind of situation that would be useful?

Ju-221 commented 5 years ago

From what I've seen in the server I deployed it, people want to check their stats, the version of the bot, or another function forked into the bot such as a backwards search in the same channel that they post in as instead of moving into the interactive channel. The easy fix is to have a dedicated #bot channel and use all arguments there. I think is more about accessibility than an issue at this point tho.