yourWaifu / sleepy-discord

C++ library for the Discord chat client. Please use Rust for new bots
https://yourWaifu.github.io/sleepy-discord/
MIT License
707 stars 95 forks source link

does not exist or is not a namespace #97

Closed Moulijin closed 6 years ago

Moulijin commented 6 years ago

I followed the documentation step by step but, I am getting 22 error that SleepDiscord and its functions does not exist or is not a namespace

image

yourWaifu commented 6 years ago

I'm going to guess that you are missing websocket++. Check that you have a folder named websocketpp inside deps/include.

Moulijin commented 6 years ago

I have it

image

yourWaifu commented 6 years ago

ok good make sure some files are in that folder but are you compiling this using the config from the example folder or did you do the config yourself using the link guide? if you did the config yourself, I would like to see your include directories.

Moulijin commented 6 years ago

image and the evaluated value shows correct

yourWaifu commented 6 years ago

there go, that's the issue.

Also, it is important to note that the order of these folders matter. The compiler will look at the first path first, and and the 2nd one next, so \include\sleepy_discord\IncludeNonexistent needs to be last.

https://yourwaifu.github.io/sleepy-discord/link.html#include-directories

Moulijin commented 6 years ago

ok, now it's showing

image

yourWaifu commented 6 years ago

did you compile tho?

Moulijin commented 6 years ago

yes now it showing image

yourWaifu commented 6 years ago

Did you make the change to all configurations, both Release and Debug?

Moulijin commented 6 years ago

yes, still same error

yourWaifu commented 6 years ago

the include directories window, right below the list of directories is the list of evaluated values. Make sure that they lead to the correct folders. For example:

C:\Users\steve\Documents\nsprojects\sleepy_discord\deps\include
yourWaifu commented 6 years ago

I want you to try this, and show me the result. right click on "sleepy_discord/websocketpp_websocket.h", and left click on Open Document. And do the same thing for <websocketpp/config/asio_client.hpp> Tell me what happens. Does it go to a file with #define NONEXISTENT_WEBSOCKETPP or does it go somewhere else?

Moulijin commented 6 years ago

image

yourWaifu commented 6 years ago

umm that's not right First of all, the path to asio_client is going to the wrong file. It should be going to deps\websocketpp\config\asio_client. 2nd, the path doesn't make any sense, shouldn't include come before sleepy_discord\IncludeNonexistent according to one of your screenshot? 3rd, you shouldn't be hard coding the full path to the file, you're making it harder to compile it on other machines. 4th, I asked you to also right click on <websocketpp/config/asio_client.hpp> (The one that's not in a comment) and open the document.

yourWaifu commented 6 years ago

ok, I managed to fix it

it would be great if you tell me how if you know how you fixed it in case others come here and find this

What version of the library are you using, because the current version doesn't have that variable. Other then that, it should be std::condition_variable* condition = nullptr. It's missing a * for some reason. https://github.com/yourWaifu/sleepy-discord/blob/master/include/sleepy_discord/client.h https://github.com/yourWaifu/sleepy-discord/commit/3580a2b95179938b4d1f0338f60f4c797044e30a#diff-b17ee23637b770c383c1a16159a23cbaL298

Moulijin commented 6 years ago

What i did is I replaced the hard coded path to #include <websocketpp/config/asio_client.hpp> and gave me the std::condition_variable condition = nullptr error. I added the asterisk and worked but, now is giving me cannot open input file libcurl. So, i'm working on it now. following the https://stackoverflow.com/questions/20171165/getting-libcurl-to-work-with-visual-studio-2013/32168255#32168255 guide

Moulijin commented 6 years ago

Now, it's just this error image

yourWaifu commented 6 years ago

Add Ws2_32.lib to your list of additional dependences and make sure you do it to all configurations.

Moulijin commented 6 years ago

Same issue

Moulijin commented 6 years ago

Issue resolved. Installed openssl through NuGet.

image

Moulijin commented 6 years ago

Good news I am able to run it. When I try to enter a sendmessage, I get an error. I tried to search through issues that other post before posting but, was not able to find one. image

yourWaifu commented 6 years ago

Have you tried to recompile Sleepy Discord? You seem to also be using some custom version of the library according to your screenshots. As according to the screenshot, there should a function that looks like this

bool startsWith(char *);

But this is wrong, as it should be this. https://github.com/yourWaifu/sleepy-discord/blob/master/include/sleepy_discord/message.h#L52

The 2nd, error also tells me that there's this function.

Message sendMessage(std::string, std::string, bool);

But this is also wrong, it should be this. https://github.com/yourWaifu/sleepy-discord/blob/master/include/sleepy_discord/client.h#L75

I'm going to guess that you might be using an old version of the library. So, I'm going to ask you to take a look those files: sleepy_discord/message.cpp and sleepy_discord/endpoints.cpp. Use ctrl + f to find, and tell me if you can find the above functions with the same types in the parameters.

Moulijin commented 6 years ago

I searched for Message sendMessage(std::string, std::string, bool); no results but, searched for the correct code and found results image

Searched for bool startsWith(char *); and no results but found bool startsWith(std::string test); image

I completed deleted sleepy_discord and tried again but , same error results

yourWaifu commented 6 years ago

The error are being caused by the fact that it's looking for functions that aren't defined. However, those functions have to have been declared else you would get Identifier not found errors.

I completed deleted sleepy_discord and tried again but , same error results

If you deleted them, then you should get different errors such as can't find include file or can't link file because the files shouldn't exist anymore. If you are get the same errors after deleting the library then the library has to still be present somewhere else.

I'm going to guess that the wrong files are being included and that you have some old version that's bring included. Use this to figure out what files are being included. https://docs.microsoft.com/en-us/cpp/build/reference/showincludes-list-include-files

Try opening the files and see if they lead to the same files that you just screenshoted.

Moulijin commented 6 years ago

I completely delete everything sleepy_discord and set it up again from scratch. I was having the same issue then I changed to Release and x86 then I was able to run it successfully. Just trying to successfully send a message now but it's not sending anything upon onReady.

image

class MyClientClass : public SleepyDiscord::DiscordClient {
private:
    using SleepyDiscord::DiscordClient::DiscordClient;
    void onReady() {
        SleepyDiscord::Message message = sendMessage("DeletedMyChannelID", "Discord services online");
        std::cout << message.content;
    }
public:
    void onMessage(SleepyDiscord::Message message) {
        if (message.startsWith("whcg hello"))
            sendMessage(message.channelID, "Hello " + message.author.username);
    }
};

here is the other init() part: PutLogList("(!) Running Discord Module.."); MyClientClass client("DeletedMyToken", 2);

yourWaifu commented 6 years ago

try using the override specifier, this will tell the compiler that you want this function to override a function and give an error when it doesn't override. https://en.cppreference.com/w/cpp/language/override

Take a look at this. https://github.com/yourWaifu/sleepy-discord/blob/master/include/sleepy_discord/client.h#L238 add std::string* jsonMessage also a little note, that I will change this in the future. https://github.com/yourWaifu/sleepy-discord/blob/develop/include/sleepy_discord/client.h#L248

Moulijin commented 6 years ago

already exists image

yourWaifu commented 6 years ago

I don't think you understand what I was trying to tell you. Let me making really clear. change this

void onReady() {

to this

void onReady(std::string* jsonMessage) override {
Moulijin commented 6 years ago

oh doh, my fault. ok looks like its working now image

Moulijin commented 6 years ago

everything works now. Thank you so much for your help!