Giter Club home page Giter Club logo

sleepy-discord's Introduction

yourwaifu

A website that will give you a randomly picked person, which resembles your perfect waifu material.

Usage

see the last point in the Installation section

Tip: Keep it running in a Screen/tmux session or otherwise it will just close again after you disconnect from your server/machine you host the site on.

Setup

Requirements

  • Ruby, should be a package simply called ruby for your *nix system.
  • An Unix system (FreeBSD and OS X work fine)
  • Bundler (install it with gem install bundler)

Installation

  • bundle install
  • copy example nginx config (nginx.conf.example) to your nginx directory and change it according to your configuration
  • edit ./config/unicorn.rb to set the amount of unicorn workers
  • run bundle exec unicorn -E production -c ./config/unicorn.rb -l unix:./yourwaifu.sock

Contributing

Missing your waifu? Here are some simply ways to get those you want onto the list:

Open an issue on GitHub

Visit the issue-page of this repository and open a new issue with the characters you want to have added, really simple!

Add them yourself and make a Pull Request

The people that feel adventurous and have a bit of coding knowledge can try adding their wishes to the bot themself, just edit the waifu.yml file and add your waifu-entries, but people keep the format of the initial entries.

Warning: Cloning this repository to a Windows-based system might not work as the folder names utilize characters that are not usable in directory-names on Windows, please choose the first option of contributing then.

Contributors

  • ch1zuru for the idea
  • nilsding for help with coding
  • SakisaKawaii for help with the request listing
  • Everyone who contributes to the list!

License

yourwaifu(bot) is licensed under the MIT License

sleepy-discord's People

Contributors

alanjian85 avatar amdoku avatar aodelta avatar autoantwort avatar azure-pipelines[bot] avatar barronkane avatar birb007 avatar crat0z avatar dencelle avatar endlessarch avatar jaredoconnell avatar kheartz avatar kiroma avatar ldelelis avatar macdue avatar magnuswright avatar max2408 avatar nyantasticuwu avatar oneechanhax avatar plisp avatar seymourgx avatar sirivasv avatar steamdragon avatar theblackwidower avatar yourwaifu 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sleepy-discord's Issues

Files and libraries are included, but project won't compile

Hi, I'm trying to use your library and I'm encountering an issue.
Screenshot from Gyazo
Screenshot from Gyazo
Nevertheless, when I peek the definition of the SleepyDiscord namespace, it takes me there:
Screenshot from Gyazo
I could never compile a project that linked sleepy_discord (not even the examples provided). I linked all the libraries and dependencies and followed your guide, but it doesn't seem to work for me.

I don't have any problem with the include directives. No errors there, but it says that SleepyDiscord namespace doesn't exist or something like that. Maybe it's a noob mistake (it's actually my first time linking libraries and so in c++, so I could've messed up somewhere).

Thanks in advance.

Develop branch and Linux complication.

I was going to try and find that stack corruption thing MSVC found with Valgrind but sleepy discord does not compile on Linux.

Using G++ or Clang.

linxerr

Missing asio_udp.h(?)

I was able to compile by deleting asio_udp.cpp (deleted header forgot to delete cpp?)

curl requests failing whenever there are backslash characters

Hi, I was initially trying to use sendMessage with a string that contained '\n', but it kept failing with a "you cannot send an empty message" error. I did some debugging and found the same problem occurred if I had backslash escaped quote marks in a string, e.g. if I tried to send the string "test "quote"".

Any ideas how to fix this?

Automation of setting up the library

Currently The user needs to follow these instructions https://yourwaifu.github.io/sleepy-discord/compile.html. However, this can be and should be automated, so that compiling or setting up the library is a more painless process. Once the library is downloaded, the user should just need to do a few things like maybe running a script and then hit compile to get up and running.

There are few things I need for this to work the way I want it to. Here's a list of things I want to have for automating the seting up the deps folder

  • Users should be able to choose libraries (like CPR, Websocketpp, or uWebSockets)
  • Users can choose to use no libraries if they wish. That should be easy, just make automation not a requirement
  • Works on Windows, macOS, and Linux
  • Download the libraries for the user and the libraries' needed libraries and compile them if they need to be compiled to compile Sleepy Discord

Compiling Sleepy Discord should be separate, because you only need to set up the deps folder once and Visual Studio has already automated compiling the library.

There have been a few people that tried tackling this issue, however none of their solutions hits all of the above.

Can't build project linked to Sleepy-Discord

I'm having trouble linking the default hello project to sleepy-discord. I've tried this process at least three times, and this is the closest I've come to getting it to compile. I'm not familiar with processes like this, so if it's something stupid I apologize.

Here's the build log:

1>------ Skipped Rebuild All: Project: sleepy_discord, Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration 
2>------ Rebuild All started: Project: hello, Configuration: Debug x64 ------
3>------ Skipped Rebuild All: Project: rock-paper-scissors, Configuration: Debug x64 ------
3>Project not selected to build for this solution configuration 
2>example0.cpp
2>c:\users\cross\desktop\sleepy-discord-master\deps\include\websocketpp\frame.hpp(831): warning C4267: '=': conversion from 'size_t' to 'uint32_t', possible loss of data
2>c:\users\cross\desktop\sleepy-discord-master\deps\include\websocketpp\common\md5.hpp(367): warning C4267: '+=': conversion from 'size_t' to 'websocketpp::md5::md5_word_t', possible loss of data
2>c:\users\cross\desktop\sleepy-discord-master\deps\include\websocketpp\sha1\sha1.hpp(176): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data
2>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\xutility(2294): error C4996: 'std::copy::_Unchecked_iterators::_Deprecate': Call to 'std::copy' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
2>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\xutility(2294): note: see declaration of 'std::copy::_Unchecked_iterators::_Deprecate'
2>c:\users\cross\desktop\sleepy-discord-master\deps\include\websocketpp\frame.hpp(255): note: see reference to function template instantiation '_OutIt std::copy<uint8_t*,uint8_t*>(_InIt,_InIt,_OutIt)' being compiled
2>        with
2>        [
2>            _OutIt=uint8_t *,
2>            _InIt=uint8_t *
2>        ]
2>Done building project "hello.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 2 skipped ==========

I haven't changed any of the code.

If you need any additional information, just ask,

compile issues

1>------ Build started: Project: sleepy_discord, Configuration: Debug Win32 ------
1>attachment.cpp
1>client.cpp
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2143: syntax error: missing ';' before '*'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2238: unexpected token(s) preceding ';'
1>client.cpp(46): error C2065: 'Session': undeclared identifier
1>client.cpp(46): error C2146: syntax error: missing ';' before identifier 'session'
1>client.cpp(46): error C2065: 'session': undeclared identifier
1>client.cpp(48): error C2065: 'session': undeclared identifier
1>client.cpp(48): error C2228: left of '.setUrl' must have class/struct/union
1>client.cpp(48): note: type is 'unknown-type'
1>client.cpp(50): error C2065: 'session': undeclared identifier
1>client.cpp(50): error C2228: left of '.setBody' must have class/struct/union
1>client.cpp(50): note: type is 'unknown-type'
1>client.cpp(55): error C2065: 'session': undeclared identifier
1>client.cpp(55): error C2228: left of '.setMultipart' must have class/struct/union
1>client.cpp(55): note: type is 'unknown-type'
1>client.cpp(58): error C2065: 'session': undeclared identifier
1>client.cpp(58): error C2228: left of '.setHeader' must have class/struct/union
1>client.cpp(58): note: type is 'unknown-type'
1>client.cpp(66): error C2065: 'session': undeclared identifier
1>client.cpp(66): error C2228: left of '.Post' must have class/struct/union
1>client.cpp(66): note: type is 'unknown-type'
1>client.cpp(67): error C2065: 'session': undeclared identifier
1>client.cpp(67): error C2228: left of '.Patch' must have class/struct/union
1>client.cpp(67): note: type is 'unknown-type'
1>client.cpp(68): error C2065: 'session': undeclared identifier
1>client.cpp(68): error C2228: left of '.Delete' must have class/struct/union
1>client.cpp(68): note: type is 'unknown-type'
1>client.cpp(69): error C2065: 'session': undeclared identifier
1>client.cpp(69): error C2228: left of '.Get' must have class/struct/union
1>client.cpp(69): note: type is 'unknown-type'
1>client.cpp(70): error C2065: 'session': undeclared identifier
1>client.cpp(70): error C2228: left of '.Put' must have class/struct/union
1>client.cpp(70): note: type is 'unknown-type'
1>client.cpp(146): error C2039: 'mutex': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>client.cpp(146): error C2065: 'mutex': undeclared identifier
1>client.cpp(146): error C2146: syntax error: missing ';' before identifier 'mut'
1>client.cpp(146): error C2065: 'mut': undeclared identifier
1>client.cpp(147): error C2039: 'unique_lock': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>client.cpp(147): error C2065: 'unique_lock': undeclared identifier
1>client.cpp(147): error C2039: 'mutex': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>client.cpp(147): error C2065: 'mutex': undeclared identifier
1>client.cpp(147): error C2065: 'mut': undeclared identifier
1>client.cpp(147): error C3861: 'lock': identifier not found
1>client.cpp(148): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>client.cpp(148): error C2065: 'condition_variable': undeclared identifier
1>client.cpp(148): error C2146: syntax error: missing ';' before identifier 'variable'
1>client.cpp(148): error C2065: 'variable': undeclared identifier
1>client.cpp(149): error C2065: 'condition': undeclared identifier
1>client.cpp(149): error C2065: 'variable': undeclared identifier
1>client.cpp(150): error C2065: 'condition': undeclared identifier
1>client.cpp(150): error C2227: left of '->wait' must point to class/struct/union/generic type
1>client.cpp(150): note: type is 'unknown-type'
1>client.cpp(150): error C2065: 'lock': undeclared identifier
1>client.cpp(152): error C2065: 'condition': undeclared identifier
1>client.cpp(161): error C2065: 'Session': undeclared identifier
1>client.cpp(161): error C2146: syntax error: missing ';' before identifier 'session'
1>client.cpp(161): error C2065: 'session': undeclared identifier
1>client.cpp(162): error C2065: 'session': undeclared identifier
1>client.cpp(162): error C2228: left of '.setUrl' must have class/struct/union
1>client.cpp(162): note: type is 'unknown-type'
1>client.cpp(163): error C2065: 'session': undeclared identifier
1>client.cpp(163): error C2228: left of '.Post' must have class/struct/union
1>client.cpp(163): note: type is 'unknown-type'
1>client.cpp(172): warning C4996: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::copy': Call to 'std::basic_string::copy' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\xstring(3096): note: see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::copy'
1>client.cpp(327): error C2065: 'condition': undeclared identifier
1>client.cpp(327): error C2227: left of '->notify_all' must point to class/struct/union/generic type
1>client.cpp(327): note: type is 'unknown-type'
1>cpr_session.cpp
1>default_functions.cpp
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2143: syntax error: missing ';' before '*'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2238: unexpected token(s) preceding ';'
1>auth.cpp
1>deps\cpr\cpr\auth.cpp(1): fatal error C1083: Cannot open include file: 'cpr/auth.h': No such file or directory
1>cookies.cpp
1>deps\cpr\cpr\cookies.cpp(1): fatal error C1083: Cannot open include file: 'cpr/cookies.h': No such file or directory
1>cprtypes.cpp
1>deps\cpr\cpr\cprtypes.cpp(1): fatal error C1083: Cannot open include file: 'cpr/cprtypes.h': No such file or directory
1>digest.cpp
1>deps\cpr\cpr\digest.cpp(1): fatal error C1083: Cannot open include file: 'cpr/digest.h': No such file or directory
1>error.cpp
1>deps\cpr\cpr\error.cpp(1): fatal error C1083: Cannot open include file: 'cpr/error.h': No such file or directory
1>multipart.cpp
1>deps\cpr\cpr\multipart.cpp(1): fatal error C1083: Cannot open include file: 'cpr/multipart.h': No such file or directory
1>parameters.cpp
1>deps\cpr\cpr\parameters.cpp(1): fatal error C1083: Cannot open include file: 'cpr/parameters.h': No such file or directory
1>payload.cpp
1>deps\cpr\cpr\payload.cpp(1): fatal error C1083: Cannot open include file: 'cpr/payload.h': No such file or directory
1>proxies.cpp
1>deps\cpr\cpr\proxies.cpp(1): fatal error C1083: Cannot open include file: 'cpr/proxies.h': No such file or directory
1>session.cpp
1>deps\cpr\cpr\session.cpp(1): fatal error C1083: Cannot open include file: 'cpr/session.h': No such file or directory
1>util.cpp
1>deps\cpr\cpr\util.cpp(1): fatal error C1083: Cannot open include file: 'cpr/util.h': No such file or directory
1>discord_object_interface.cpp
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2143: syntax error: missing ';' before '*'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2238: unexpected token(s) preceding ';'
1>embed.cpp
1>endpoints.cpp
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2143: syntax error: missing ';' before '*'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2238: unexpected token(s) preceding ';'
1>experimental.cpp
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2143: syntax error: missing ';' before '*'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2238: unexpected token(s) preceding ';'
1>message.cpp
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2143: syntax error: missing ';' before '*'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2238: unexpected token(s) preceding ';'
1>Generating Code...
1>Compiling...
1>sd_error.cpp
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2143: syntax error: missing ';' before '*'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2238: unexpected token(s) preceding ';'
1>server.cpp
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2039: 'condition_variable': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\map(16): note: see declaration of 'std'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2143: syntax error: missing ';' before '*'
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\dokumente\discord bot c++\sleepy_discord\client.h(295): error C2238: unexpected token(s) preceding ';'
1>websocketpp_websocket.cpp
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(42): error C2589: '(': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(42): error C2062: type 'unknown-type' unexpected
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(42): error C2059: syntax error: ')'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(45): error C2589: ';': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(46): error C2589: ';': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(46): error C2144: syntax error: 'unknown-type' should be preceded by ';'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(53): error C2143: syntax error: missing ';' before '}'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(63): error C2589: ';': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(64): error C2589: ';': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(64): error C2144: syntax error: 'unknown-type' should be preceded by ';'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(65): error C2589: 'while': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(65): error C2144: syntax error: 'unknown-type' should be preceded by ';'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(65): error C2059: syntax error: 'constant'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(71): error C2589: 'while': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(71): error C2059: syntax error: 'constant'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(72): error C2589: 'while': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(72): error C2059: syntax error: 'constant'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(75): error C2589: 'while': illegal token on right side of '::'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/openssl_init.ipp(75): error C2059: syntax error: 'constant'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(82): error C2039: 'SSLv2_method': is not a member of '`global namespace''
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(82): error C3861: 'SSLv2_method': identifier not found
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(85): error C2039: 'SSLv2_client_method': is not a member of '`global namespace''
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(85): error C3861: 'SSLv2_client_method': identifier not found
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(88): error C2039: 'SSLv2_server_method': is not a member of '`global namespace''
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(88): error C3861: 'SSLv2_server_method': identifier not found
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(92): error C2039: 'SSLv3_method': is not a member of '`global namespace''
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(92): error C3861: 'SSLv3_method': identifier not found
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(95): error C2039: 'SSLv3_client_method': is not a member of '`global namespace''
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(95): error C3861: 'SSLv3_client_method': identifier not found
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(98): error C2039: 'SSLv3_server_method': is not a member of '`global namespace''
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(98): error C3861: 'SSLv3_server_method': identifier not found
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(198): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(198): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(202): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(202): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(204): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(204): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(541): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(541): error C2227: left of '->default_passwd_callback' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(542): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(542): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(542): error C2660: 'PEM_read_bio_X509_AUX': function does not take 2 arguments
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(559): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(559): error C2227: left of '->extra_certs' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(561): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(561): error C2227: left of '->extra_certs' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(562): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(562): error C2227: left of '->extra_certs' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(566): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(566): error C2227: left of '->default_passwd_callback' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(567): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(567): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(567): error C2660: 'PEM_read_bio_X509': function does not take 2 arguments
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(643): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(643): error C2227: left of '->default_passwd_callback' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(644): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(644): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(644): error C2660: 'PEM_read_bio_PrivateKey': function does not take 2 arguments
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(702): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(702): error C2227: left of '->default_passwd_callback' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(703): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(703): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(703): error C2660: 'PEM_read_bio_RSAPrivateKey': function does not take 2 arguments
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(922): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(922): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(924): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(924): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(926): error C2027: use of undefined type 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ossl_typ.h(145): note: see declaration of 'ssl_ctx_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/impl/context.ipp(926): error C2227: left of '->default_passwd_callback_userdata' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/engine.ipp(206): error C2065: 'SSL_R_SHORT_READ': undeclared identifier
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/engine.ipp(207): error C2440: '<function-style-cast>': cannot convert from 'const asio::error_category' to 'asio::error_code'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/engine.ipp(207): note: No constructor could take the source type, or constructor overload resolution was ambiguous
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/engine.ipp(213): error C2027: use of undefined type 'ssl_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\openssl/ssl.h(224): note: see declaration of 'ssl_st'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/engine.ipp(213): error C2227: left of '->version' must point to class/struct/union/generic type
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/engine.ipp(220): error C2065: 'SSL_R_SHORT_READ': undeclared identifier
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/engine.ipp(221): error C2440: '<function-style-cast>': cannot convert from 'const asio::error_category' to 'asio::error_code'
1>D:\Dokumente\discord bot c++\sleepy_discord\deps\asio/ssl/detail/impl/engine.ipp(221): note: No constructor could take the source type, or constructor overload resolution was ambiguous
1>Generating Code...
1>Done building project "sleepy_discord.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

i guess im just dumb

P.s. I reinstalled Visual Studio 4 times due to corrupt installations and shit not working during the cause of compiling the components (except openssl where i gave up and downloaded binaries) which is why im completely done with compiling shit and looking into errors for hours.

Build failed. Message.cpp and server.cpp

1>message.cpp
1>message.cpp(35): warning C4003: not enough actual parameters for macro 'modIfElse'
1>message.cpp(35): error C2660: 'SleepyDiscord::DiscordObject::isDefined': function does not take 0 arguments
1>message.cpp(35): warning C4353: nonstandard extension used: constant 0 as function expression.  Use '__noop' function intrinsic instead
1>server.cpp
1>server.cpp(64): warning C4002: too many actual parameters for macro 'setIfElse'
1>server.cpp(64): error C2059: syntax error: ';'
1>Generating Code...
1>Done building project "sleepy_discord.vcxproj" -- FAILED.

Not much of an issue

I wanted to know more about this project, and talking about this. I do guess this project has a discord server,
I would love to get in touch with the devs as i am also a C++ programmer.

Automated Updating

It would be very helpful to check updates and download them automatically.

Automated Testing

Everything in the library including its multiple configurations needs to be tested to ensure everything is operational. Currently, right now, most things aren't even tested and that is an issue. It would also be nice to get this work with pull requests.

sendMessage with certain characters

If you use sendMessage with a quote in it the Discord.

 			if (message.content == "test")
 			{
 				sendMessage(message.channelID, "Test:");
 				sendMessage(message.channelID, "\"");
 			}

Error 400: The request was improperly formatted, or the server couldn't understand it
Error 50006: Cannot send an empty message

Are the characters in the post request (or whatever this does) escaped properly?

"How to Compile Sleepy Discord" documentation has conflicting images and instructions

Currently the documentation supplies two main ways of building the library. I was having problems with the "automated" system so I chose to do it by hand. Choosing to manually build it, I've ran into conflicting or contradicting instructions or photos.

Working strictly within the created "deps" folder you're asked to move the cpr-master folder from within the cpr zip then rename it to cpr.

Then from the context which I understood the instructions I'm asked to then take the "include" folder from within the newly renamed cpr folder and move it back to the "deps" folder.

Currently, the photos match up with what I'm asked to do.

Then I was asked to reenter the "cpr" folder and navigate to "opt/curl" then place the contents of the downloaded "curl" folder into "opt/curl." The final step within the "curl" folder involves building it via the supplied "buildconf.bat" if on Windows.

Moving onto the addition of Websocket++ and Asio 1.10.8 I ran into the first issue.

You are asked to move the downloaded "websocketpp" folder into "deps/include" and in addition you are asked to move the "asio" folder and the "asio.hpp" file within "asio-1.10.8/include" to your "deps/include" folder. If you check against the provided photos you'll find that "deps/include" will only ever contain the "cpr" and "openssl" folder, while the photo shows that "deps" will instead contain the folders and file you are asked to move to the "deps/include" folder.

The second set of instructions regards OpenSSL. Using the npcglib.org website provided you'll find that the VS2017 7z contains another "openssl" folder within it. Going strictly off of the photos I dragged the "include/openssl" folder to the created "deps/include/openssl" folder.

I took some time to check this against the folder structure of the automated setup and found that the automated "deps/include/openssl" does not contain another "openssl" folder but the contents of the downloaded "include/openssl."

I'm having issues with the automated setup and I'm having trouble clearly understanding what is asked within the manual setup.

Debian9 -lsleepy_discord linking issues

After installing all needed libraries and packages and successfully compiling sleepy_discord, when compiling the hello example, I get linking errors with libsleepy_discord:

nigel@dontdeleteme:~/Documents/SleepyDiscord/sleepy-discord/examples/hello$ g++ -std=c++11 -I ../../include -I ../../deps -I ../../deps/include -I ../../include/sleepy_discord/IncludeNonexistant -L../../buildtools -L/usr/lib -lsleepy_discord -lcurl -lssl -lcrypto example0.cpp -o example.out
/usr/bin/ld: /tmp/ccsWbvjx.o: undefined reference to symbol 'pthread_join@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
nigel@dontdeleteme:~/Documents/SleepyDiscord/sleepy-discord/examples/hello$ g++ -std=c++11 -I ../../include -I ../../deps -I ../../deps/include -I ../../include/sleepy_discord/IncludeNonexistant -L../../buildtools -L/usr/lib -pthread -lsleepy_discord -lcurl -lssl -lcrypto example0.cpp -o example.out
/tmp/ccYirsUv.o: In function `main':
example0.cpp:(.text+0x10ef): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::run()'
/tmp/ccYirsUv.o: In function `myClientClass::onMessage(SleepyDiscord::Message)':
example0.cpp:(.text._ZN13myClientClass9onMessageEN13SleepyDiscord7MessageE[_ZN13myClientClass9onMessageEN13SleepyDiscord7MessageE]+0x5b): undefined reference to `SleepyDiscord::Message::startsWith(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
example0.cpp:(.text._ZN13myClientClass9onMessageEN13SleepyDiscord7MessageE[_ZN13myClientClass9onMessageEN13SleepyDiscord7MessageE]+0xdf): undefined reference to `SleepyDiscord::BaseDiscordClient::sendMessage(SleepyDiscord::Snowflake<SleepyDiscord::Channel>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool)'
/tmp/ccYirsUv.o: In function `myClientClass::myClientClass(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char)':
example0.cpp:(.text._ZN13myClientClassC2ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEc[_ZN13myClientClassC5ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEc]+0x41): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::WebsocketppDiscordClient(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char)'
/tmp/ccYirsUv.o: In function `myClientClass::~myClientClass()':
example0.cpp:(.text._ZN13myClientClassD2Ev[_ZN13myClientClassD5Ev]+0x22): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::~WebsocketppDiscordClient()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x10): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::run()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x18): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::schedule(std::function<void ()>, long)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x20): undefined reference to `SleepyDiscord::BaseDiscordClient::onReady(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x28): undefined reference to `SleepyDiscord::BaseDiscordClient::onResumed(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x30): undefined reference to `SleepyDiscord::BaseDiscordClient::onDeleteServer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x38): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditServer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x40): undefined reference to `SleepyDiscord::BaseDiscordClient::onBan(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x48): undefined reference to `SleepyDiscord::BaseDiscordClient::onUnban(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x50): undefined reference to `SleepyDiscord::BaseDiscordClient::onMember(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x58): undefined reference to `SleepyDiscord::BaseDiscordClient::onRemoveMember(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x60): undefined reference to `SleepyDiscord::BaseDiscordClient::onDeleteMember(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x68): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditMember(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x70): undefined reference to `SleepyDiscord::BaseDiscordClient::onRole(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x78): undefined reference to `SleepyDiscord::BaseDiscordClient::onDeleteRole(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x80): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditRole(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x88): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditEmojis(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x90): undefined reference to `SleepyDiscord::BaseDiscordClient::onMemberChunk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x98): undefined reference to `SleepyDiscord::BaseDiscordClient::onDeleteChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xa0): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xa8): undefined reference to `SleepyDiscord::BaseDiscordClient::onPinMessages(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xb0): undefined reference to `SleepyDiscord::BaseDiscordClient::onPresenceUpdate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xb8): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditUser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xc0): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditUserNote(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xc8): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditUserSettings(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xd0): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditVoiceState(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xd8): undefined reference to `SleepyDiscord::BaseDiscordClient::onTyping(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xe0): undefined reference to `SleepyDiscord::BaseDiscordClient::onDeleteMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xe8): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xf0): undefined reference to `SleepyDiscord::BaseDiscordClient::onBulkDelete(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0xf8): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditVoiceServer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x100): undefined reference to `SleepyDiscord::BaseDiscordClient::onServerSync(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x108): undefined reference to `SleepyDiscord::BaseDiscordClient::onRelationship(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x110): undefined reference to `SleepyDiscord::BaseDiscordClient::onRemoveRelationship(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x118): undefined reference to `SleepyDiscord::BaseDiscordClient::onDeleteRelationship(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x120): undefined reference to `SleepyDiscord::BaseDiscordClient::onReaction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x128): undefined reference to `SleepyDiscord::BaseDiscordClient::onRemoveReaction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x130): undefined reference to `SleepyDiscord::BaseDiscordClient::onDeleteReaction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x138): undefined reference to `SleepyDiscord::BaseDiscordClient::onRemoveAllReaction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x140): undefined reference to `SleepyDiscord::BaseDiscordClient::onDeleteAllReaction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x150): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditedMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x158): undefined reference to `SleepyDiscord::BaseDiscordClient::onServer(SleepyDiscord::Server)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x160): undefined reference to `SleepyDiscord::BaseDiscordClient::onChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x168): undefined reference to `SleepyDiscord::BaseDiscordClient::onEditedRole(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x170): undefined reference to `SleepyDiscord::BaseDiscordClient::onDispatch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x178): undefined reference to `SleepyDiscord::BaseDiscordClient::onHeartbeat()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x180): undefined reference to `SleepyDiscord::BaseDiscordClient::onHeartbeatAck()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x188): undefined reference to `SleepyDiscord::BaseDiscordClient::onInvaldSession()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x190): undefined reference to `SleepyDiscord::BaseDiscordClient::onDisconnect()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x198): undefined reference to `SleepyDiscord::BaseDiscordClient::onResume()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1a0): undefined reference to `SleepyDiscord::BaseDiscordClient::onQuit()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1a8): undefined reference to `SleepyDiscord::BaseDiscordClient::onResponse(SleepyDiscord::Response)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1b0): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::sleep(unsigned int)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1b8): undefined reference to `SleepyDiscord::BaseDiscordClient::fileRead(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1c0): undefined reference to `SleepyDiscord::BaseDiscordClient::tick(float)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1c8): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::onError(SleepyDiscord::ErrorCode, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1d0): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1d8): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::send(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1e0): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::disconnect(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1e8): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::runAsync()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTV13myClientClass[_ZTV13myClientClass]+0x1f0): undefined reference to `SleepyDiscord::BaseDiscordClient::getEpochTimeMillisecond()'
/tmp/ccYirsUv.o:(.data.rel.ro._ZTI13myClientClass[_ZTI13myClientClass]+0x10): undefined reference to `typeinfo for SleepyDiscord::WebsocketppDiscordClient'
collect2: error: ld returned 1 exit status

I am on Debian 9.4.0 with g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

You may also want to add -pthread to the tutorial as it is needed on linux.

Further notes, just incase, I also tried to compile sleepy_discord with -pthread, but I don't believe it is necessary as it compiles either way. Same end result with and without it.

Also, I ran the setup.py with options 1 and 0 1, everything was successful.

Initially, when trying to compile, I ran into the issue with openssl where SSL_R_SHORT_READ is undefined, I fixed this by applying this patch: LocutusOfBorg/websocketpp@1dd0711

After applying the patch and successfully making, the file ./buildtools/libsleepy_discord.a exists and is seemingly found by the linker.

Upon further investigation, I found this:

nigel@dontdeleteme:~/Documents/SleepyDiscord/sleepy-discord/examples/hello$ g++ -std=c++11 -I ../../include -I ../../include/sleepy_discord -I ../../deps -I ../../deps/include -I ../../include/sleepy_discord/IncludeNonexistant -L../../buildtools -L/usr/lib -pthread -lcurl -lssl -lcrypto example0.cpp ../../sleepy_discord/*.cpp ../../sleepy_discord/*.c -o example.out
../../sleepy_discord/websocketpp_websocket.cpp: In member function โ€˜virtual SleepyDiscord::Timer SleepyDiscord::WebsocketppDiscordClient::schedule(std::function<void()>, time_t)โ€™:
../../sleepy_discord/websocketpp_websocket.cpp:59:39: error: could not convert โ€˜<lambda closure object>SleepyDiscord::WebsocketppDiscordClient::schedule(std::function<void()>, time_t)::<lambda()>{std::shared_ptr<asio::basic_waitable_timer<std::chrono::_V2::steady_clock> >(timer)}โ€™ from โ€˜SleepyDiscord::WebsocketppDiscordClient::schedule(std::function<void()>, time_t)::<lambda()>โ€™ to โ€˜SleepyDiscord::Timerโ€™
   return [timer]() { timer->cancel(); };
                                       ^

Note: Because I did not install uwebsockets, I renamed ./sleepy_discord/uwebsockets_websocket.cpp so that g++ would not include it.

However, when running make -f Makefile.linux; ./buildtools/websocketpp_websocket.o is created..

Possibly wrong conditional

Is the following check required in some cases?
https://github.com/yourWaifu/sleepy-discord/blob/master/sleepy_discord/client.cpp#L109

I've had getServers() and getRoles() fail on me with TOO_MANY_REQUESTS error from this code.

But I'm not sure if it's right to treat it as an error when Discord API tells you that you've 0 messages left but doesn't set an error status on its own. Doesn't this mean that this was the last correctly processed command?

When I completely disabled this conditional, the methods mentioned above continued to work just fine.

So far, my impression from reading about Discord API is that this check is unneeded. Sorry if I'm not understanding something here, got started with this only few days ago.

Using Sleepy Discord with Webassembly

Some people are been asking me to do this for a while now. And this is here just to remind to do so. However, I don't plan adding native web assembly support. I just need code proving that it's possible. if you are planning to help out with this, please ask me questions when you need help from me.

Examples don't compile using the documentation for Linux

(lol sorry for all these issues today)

I compiled CPR into libcpr.a and libcurl.so and included the library folder for the example in the G++ command.

ls ../../deps/lib/;g++ -std=c++11 -I ../../include -I ../../deps -I ../../deps/include -I ../../include/sleepy_discord/IncludeNonexistant -L../../deps/lib -L../../buildtools -L/usr/lib -lsleepy_discord -lcurl -lssl -lcrypto example0.cpp -o example.out
libcpr.a libcurl.so <--- Prints out the external libraries to ensure they exist.

With no luck in compiling the example on Linux
https://pastebin.com/eydHVP6j

What compiles
Sleepy Discord
CPR

What doesn't
/examples/hello

Not sure what i'm doing wrong.

Master branch fde5ee1 fails to compile

 nigel@game01:~/SleepyDiscord/sleepy-discord/buildtools$ make -f Makefile.linux 
g++  -Wall -c -std=c++11 -fPIC  ../sleepy_discord/*.cpp ../sleepy_discord/*.c ../deps/cpr/cpr/*.cpp  -I ../include/sleepy_discord  -I ../deps/include  -I ../include/sleepy_discord/IncludeNonexistent
../sleepy_discord/websocketpp_websocket.cpp: In member function โ€˜virtual SleepyDiscord::Timer SleepyDiscord::WebsocketppDiscordClient::schedule(std::function<void()>, time_t)โ€™:
../sleepy_discord/websocketpp_websocket.cpp:63:38: error: invalid initialization of non-const reference of type โ€˜std::shared_ptr<asio::basic_waitable_timer<std::chrono::_V2::steady_clock> >&โ€™ from an rvalue of type โ€˜websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::timer_ptr {aka std::shared_ptr<asio::basic_waitable_timer<std::chrono::_V2::steady_clock> >}โ€™
   auto& timer = this_client.set_timer(
                 ~~~~~~~~~~~~~~~~~~~~~^
    milliseconds,
    ~~~~~~~~~~~~~                      
    websocketpp::lib::bind(&handleTimers, websocketpp::lib::placeholders::_1, code)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   );
   ~                                   
Makefile.linux:14: recipe for target 'libsleepy_discord.o' failed
make: *** [libsleepy_discord.o] Error 1

Compiling with clang provides a more readable error:

../sleepy_discord/websocketpp_websocket.cpp:63:9: error: non-const lvalue
      reference to type 'shared_ptr<[...]>' cannot bind to a temporary of type
      'shared_ptr<[...]>'
                auto& timer = this_client.set_timer(
                      ^       ~~~~~~~~~~~~~~~~~~~~~~

Confirmed the same issue for the develop branch

uploadFile doesn't work

Function doesn't seem to properly upload images. 400 ERROR throws. This is likely due to the format of the JSON object:

ObjectResponse<Message> BaseDiscordClient::uploadFile(Snowflake<Channel> channelID, std::string fileLocation, std::string message) {
		return request(Post, "channels/" + channelID + "/messages",
			{ { "content", message },
			{ "file", filePathPart{fileLocation} }
		}
		);

I've tried different formats looking at the Discord API documentation, but still couldn't get it to work myself.

Ex

Set Status and Server Id's

Hey waifu,
I finally managed to set sleepy discord up and running.

I just wanted to know how can I retrieve server ID from SleepyDiscord::Message

and I had an issue with setting my status, I cant seem to ever set my bot's status for some reason with the updateStatus function, doing so results in a connection issue which crashes.

cheers

Sleepy Discord Crash

Is there a way to detect sleepy discord disconnects (ie heartbeat fails) and reconnect? This has happened several times and I don't want to manually restart a bot each time.

I see SleepyDiscord::DiscordClient::reconnect(); but its private. Is there a good way to do this?

Setup.py Linux

I think setup.py moves/deletes files from deps/cpr including the headers which are required to build cpr with the default cmake/make.

Additionally the opt files in deps/cpr/opts do not download using git clone. Just an empty folder.

After manually cloning cpr and manually downloading all the opt dependencies it compiles.

Issue compiling sample project

Hi, I'm fairly new to these libraries, so it's entirely possible I royally screwed up somewhere while compiling. Regardless, whenever I try to compile the sample project (directly copy-pasted), I get these errors:

1>------ Build started: Project: BottyBoi, Configuration: Debug Win32 ------
1>Source.cpp
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.13.26128\include\xutility(2440): error C4996: 'std::copy::_Unchecked_iterators::_Deprecate': Call to 'std::copy' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.13.26128\include\xutility(2440): note: see declaration of 'std::copy::_Unchecked_iterators::_Deprecate'
1>c:\sleepy-discord\deps\include\websocketpp\frame.hpp(255): note: see reference to function template instantiation '_OutIt std::copy<uint8_t*,uint8_t*>(_InIt,_InIt,_OutIt)' being compiled
1>        with
1>        [
1>            _OutIt=uint8_t *,
1>            _InIt=uint8_t *
1>        ]
1>Done building project "BottyBoi.vcxproj" -- FAILED.

The first error is obvious enough, but the others have me stumped. It's entirely possible I'm just dumb, but I'd appreciate it if someone could make sense of these errors for me so I can fix the issues- specifically the last one about frame.hpp.

Channel Type

auto ch = DiscordPtr->getChannel(message.channelID);
std::cout << ch->type;

gives a bunch of random numbers. I assume because type is an integer and not a string.

Rate-limits seemly lasting forever

I was made aware that after getting rate limited after quickly sending too many http requests, the limit isn't lifted even after 30 minutes.

Linux make file

The Linux make file does not include -std=c++11 which is required to compile using the C++ template library.

The command passed to g++ is
"g++ -Wall -c ../sleepy_discord/*.cpp -I ../include/sleepy_discord -I ../include/sleepy_discord/IncludeNonexistent -I ../deps/include"

when it should be
"g++ -std=c++11 -Wall -c ../sleepy_discord/*.cpp -I ../include/sleepy_discord -I ../include/sleepy_discord/IncludeNonexistent -I ../deps/include"

addReaction does not work

So i called addReaction(this->serverID, this->messageID, "%F0%9F%98%95"); what happened is that no reaction appeared on the chat so that i used the emoji that was used in the documentation and still this issue.

the serverID and messageID was correct as i was able to edit the message within that channel.

However when i checked the console, it gave this long gibberish error.

Console error here...
image

Undeclared Definition

Hi, i would have send a pull, but i never used Git, or any of this repositories thing(maybe i should learn).
Anyhow in "error.h"
It misses the identifier "GENERAL_ERROR"

You can just add this code below GATEWAY_FAILED = 5002, //Could not get the gateway
GENERAL_ERROR = 58008, //Fun stuff, if you write this on a calculator and flip it it says "BOOBS"

to fix it.

Pheraps this was intentional, as a way for people to get their own error codes?

Random crashes related to "endpoint_impl.hpp"

I'm getting seemly random crashes (or exceptions) after launching a compiled build, anywhere from one hour after launching to 36 hours.

This is outside a test environment, as in, I have built a "release" version in Visual Studio and am launching an exe. Currently the bot I have built only read/writes files and tracks user data, there is nothing going on passively, only the onMessage event with an library of functions that run if onMessage starts with something.

The exception is caught by windows and offers Visual Studio debugging, which points to line 230 in "endpoint_impl.hpp". I'm a noob at C++but from what I can understand the network connection is being closed for some reason. I've build SleepyDiscord by the (confusing) guide offered using CPR, Websocket++, and uWebSockets.

I am running on Windows Server 2016 x64, and built the bot with 32 bit settings for the release exe.

Any help is appreciated, if I need to provide more information just say and I'll collect it.

Question: Direct Messages

I have the snowflake id for the user. How do I send a direct message to said user or convert a user snowflake to a channel snowflake?

Documentation doesn't address direct messages.

Edit: Nevermind I guess ill store the channelid aswell.

SleepyDiscord::DiscordClient::run() always exits when finished or disconnected

I'm unable to return back to the rest of my code once I've run the run() function.

Maybe it's just me, but I feel like my program should be able to try to recover in the event of an error instead of just crashing.. I tried wrapping the run() in a try block, but that solved nothing.

My code (it is a shared library loaded by dlfcn.h):

#define SLEEPY_ONE_THREAD // only use one thread because run() needs to be ran in its own thread

#include "sleepy_discord/websocketpp_websocket.h"
#include "halfmod.h"
#include <thread>
#include "discord_token.h" // defines DISCORD_TOKEN
#include <ctime>
#include <fstream>
#include "str_tok.h"

void internalQuit(SleepyDiscord::Message message, hmPlayer *player);

class myClientClass : public SleepyDiscord::DiscordClient {
public:
    using SleepyDiscord::DiscordClient::DiscordClient;
    void onMessage(SleepyDiscord::Message message)
    {
        bool ignore = false;
        for (auto it = ignoredChannels.begin(), ite = ignoredChannels.end();it != ite;++it)
        {
            if (*it == message.channelID)
            {
                ignore = true;
                break;
            }
        }
        if (!ignore)
        {
            bool prefixed = message.startsWith(cmdPrefix);
            std::string unprefixed = message.content;
            std::string cmd = "";
            std::string args = "";
            std::string id = std::string(message.author.ID);
            hmPlayer *player = nullptr;
            for (auto it = accounts.begin(), ite = accounts.end();it != ite;++it)
                if (it->userID == id)
                    player = &it->player;
            if (prefixed)
            {
                unprefixed.erase(0,cmdPrefix.size());
                cmd = unprefixed;
                size_t pos = unprefixed.find_first_of(" ");
                if (pos != std::string::npos)
                    cmd.erase(pos,std::string::npos);
                if (unprefixed.size() > cmd.size())
                {
                    args = unprefixed;
                    args.erase(0,cmd.size()+1);
                }
                if (cmd == "quit")
                    internalQuit(message,player);
                //else .... unimportant snip
            }
		    for (auto it = triggers.begin(), ite = triggers.end();it != ite;++it)
		        if (it->trigger & SLEEPY_MESSAGE)
		            if ((!it->prefix) || ((it->prefix) && (prefixed)))
	                    if ((*it->func)(message.content,cmd,args,message.author.username,player,std::string(message.channelID),std::string(message.author.ID),(void*)&message))
	                        break;
        }
	}
	void onError(SleepyDiscord::ErrorCode errorCode, const std::string errorMessage)
	{
	    hmOutDebug(errorMessage);
    }
};

extern "C" {

myClientClass *discord;

void botConnect()
{
    loadAccounts();
    if (discord == nullptr)
    {
        std::thread([&]
        {
            try
            {
                discord->run();
            }
            catch (SleepyDiscord::ErrorCode err)
            {
                hmOutDebug("SleepyDiscord error code: " + to_string(int(err)));
            }
            hmOutDebug("Discord disconnected.");
        }).detach();
    }
}

void botDisconnect()
{
    //discord->stop(); // undefined?
    discord->quit();
}

int onExtensionLoad(hmExtension &handle, hmGlobal *global) // this function is called upon loading the module
{
    cmdPrefix = DEFAULT_PREFIX;
    discord = (myClientClass*)new myClientClass(DISCORD_TOKEN);
    recallGlobal(global);
    handle.extensionInfo("Discord Bot",
                         "nigel",
                         "Connect halfMod to Discord",
                         VERSION,
                         "http://discord.justca.me/in/minecraft");
    botConnect();
    handle.createTimer("msgBuffer",250,"sendBuffer","",MILLISECONDS);
    handle.hookPattern("message","^\\[[0-9]{2}:[0-9]{2}:[0-9]{2}\\] \\[Server thread/INFO\\]: <(\\S+?)> !discordlink (.+)$","confirmRecv");
    return 0;
}

}

void internalQuit(SleepyDiscord::Message message, hmPlayer *player)
{
    if ((player == nullptr) || ((player->flags & FLAG_CHAT) == 0))
        dcBuffer.push_back({message.channelID,"Sorry, " + message.author.username + ", you do not have access to this command."});
    else
    {
        discord->sendMessage(message.channelID,"I wish I could have been more useful :(");
        botDisconnect();
    }
}

Program output:

nigel@game01:~/current_halfmod$ ./halfmod_engine --debug localhost 9422
Extension "Discord Bot" loaded . . .
Plugin "Base Player Info" loaded . . .
Plugin "Reserved Slots" loaded . . .
Plugin "URLChat" loaded . . .
Plugin "Logs" loaded . . .
Plugin "Votes" loaded . . .
Plugin "Session Flags" loaded . . .
Plugin "Admin Commands" loaded . . .
[DEBUG] Error: No connection to the halfShell server . . .
Plugin "Mailbox" loaded . . .
[DEBUG] Error: Minimum Minecraft version for "disco" plugin is 1.13 official or snapshot 17w50a
Error loading plugin "./halfMod/plugins/disco.hmo" . . .
Plugin "MOTD" loaded . . .
Plugin "GeoIP" loaded . . .
Plugin "Discord Relay" loaded . . .
Plugin "Gamerule Cvars" loaded . . .
Link established with halfShell v0.3.3-build14
[2018-04-08 05:08:11] [connect] Successful connection
[05:08:11] [Server thread/INFO]: There are 0 of a max 20 players online: 
[2018-04-08 05:08:11] [connect] WebSocket Connection 104.16.59.37:443 v-2 "WebSocket++/0.7.0" /?v=6 101
[05:08:33] [Discord thread/MSG]: [nigel] Alrighty, I need to force halfBot to crashpooppoo sdafidkhow
[05:08:48] [Discord thread/MSG]: [nigel] oh
[05:08:57] [Discord thread/MSG]: [nigel] !quit
[2018-04-08 05:08:57] [warning] got non-close frame while closing
[2018-04-08 05:08:57] [error] handle_read_frame error: asio.ssl.stream:1 (stream truncated)
[2018-04-08 05:09:02] [disconnect] Disconnect close local:[1006,stream truncated] remote:[1000]
terminating with uncaught exception of type websocketpp::exception: Bad Connection
Aborted

Sorry for the extra code and output, but thought it might prove somewhat helpful.

TL;DR:
When calling SleepyDiscord::DiscordClient::quit() the program will hang until what I assume is a heartbeat that notices it's no longer connected, throws an uncaught exception and exits without allowing the rest of the program to finish running its course. This also happens when any error occurs.

Having trouble compiling

Hi there!

When I try to compile SleepyDiscord it throws all these lovely errors: https://pastebin.com/DyJZGwT1. For the most part they are "The command exited with code 9009". Im on windows 10, using VS15 and Websocket++. I used the setup script and everything went smoothly until I went to compile. What am I missing?

cannot open file sleepy_discord.lib

Hi,

In my deps/lib file I don't seem to have a sleepy_discord.lib file. I am getting an error cannot open file sleepy_discord.lib when compiling an example. I have included them in the linker input.

Any help is appreciated
image

updateStatus not working

Hey, when I use updateStatus, the server disconnects, because he doesn't know that opcode.

The problem is, the discord team has updated the version 6 of the gateway.

Here is my solution code:

enum GameType {
	game = 0,
	streaming = 1,
	listening = 2
};

enum Status {
	online = 0,
	dnd = 1,
	idle = 2,
	invisible = 3,
	offline = 4
};

std::map<int, std::string> statusMap = { { 0, "online" }, { 1, "dnd" }, { 2, "idle" }, { 3, "invisble" }, { 4, "offline"} };

void BaseDiscordClient::updateStatus(std::string gameName, GameType gameType, Status status, bool afk, uint64_t idleSince) {
	sendL(SleepyDiscord::json::createJSON({
		{ "op", SleepyDiscord::json::integer(STATUS_UPDATE) },
		{ "d", SleepyDiscord::json::createJSON({
			{ "since", idleSince != 0 ? SleepyDiscord::json::UInteger(idleSince) : "null" },
			{ "game", gameName != "" ? SleepyDiscord::json::createJSON({
				{ "name", SleepyDiscord::json::string(gameName) },
				{ "type", SleepyDiscord::json::integer(gameType)}
			}) : "null" },
			{ "status", SleepyDiscord::json::string(statusMap[status]) },
			{ "afk", SleepyDiscord::json::boolean(afk) }
		}) }
	}));
}

BUT please add the streaming url to the game tab

Cannot open libcurl_a.lib

Probably some stupid nooby mistake, but when I try to build sleepy_discord it requires the cpr files, and after I got those, it said it couldn't open libcurl_a.lib. Help would be appreciated lol

Random disconnection due to truncated stream

So my current setup is I'm running on windows with CPR and Websocket++ as I've been having trouble compiling uWebsockets. So after a minute or so of running your rock paper scissors or the hello program I get the error:

[2017-11-24 13:20:02] [error] handle_read_frame error: asio.ssl.stream:1 (stream truncated)
[2017-11-24 13:20:02] [info] asio async_write error: asio.ssl:336396495 (protocol is shutdown)
[2017-11-24 13:20:02] [fatal] handle_write_frame error: websocketpp.transport:2 (Underlying Transport Error)
[2017-11-24 13:20:02] [info] asio async_shutdown error: asio.ssl.stream:1 (stream truncated)
[2017-11-24 13:20:02] [disconnect] Disconnect close local:[1006,Underlying Transport Error] remote:[1000]

I understand that this is most likely a problem with CPR or Websocket++, but these we're downloaded using the automated setup so there might be a problem there and I was wondering If you had this working and if so what platform and library versions are you using?

createDirectMessageChannel crashes

DirectMessageChannel::DirectMessageChannel(const std::vector<std::string> values) :
		//variable       modifier value                    field
		ID             (         values[index(fields, "id"             )] ),
		is_private     ( getBool(values[index(fields, "is_private"     )])),
		recipient      ( User(  &values[index(fields, "recipient"      )])),
		lastMessageID  (         values[index(fields, "last_message_id")] )
	{}

	const std::initializer_list<const char*const> DirectMessageChannel::fields = {
		"id", "is_private", "recipient", "last_message_id"
	};

Upon assigning recipient, program crashes. Discord now uses an array of users in the JSON object as "recipients" (note the plural). Easy fix by adding the 's' where necessary, but not going to do a pull request since SFG may want to change even more to this.
Output of the raw JSON

raw json

Calling getUser once results in error.

Calling this exactly once results in this error.
getUser(id);

Error 404: The resource at the location specified doesn't exist
Error 429: You've made too many requests
Error 429: You've made too many requests
Error 429: You've made too many requests

Also getUser(id)->username also crashes but for a different reason. Almost every get call does this including getServers, getUser, listMembers.

Visual Studio 2017 Compile Failure

This code in websocketpp_websocket.cpp Line 62

Timer WebsocketppWebsocketClient::schedule(std::function<void()> code, const time_t milliseconds) {
		auto& timer = this_client.set_timer(
			milliseconds,
			websocketpp::lib::bind(&handleTimers, websocketpp::lib::placeholders::_1, code)
		);
		return Timer([timer]() {
			timer->cancel();
		});
	}

Causes the build to fail because there is no such class called WebsocketppWebsocketClient. Commenting this out allowed the build to succeed in VS2017

Additionally, the Windows SDK (for some reason) is set in the build properties. This causes build failure on newer versions of the Windows SDK. But it's easy to re-target the project.

LibCurl and the Setup.py

LibCurl fails to install using the Setup.py.

Warning: The curl manual could not be integrated in the source. This means when
you build curl the manual will not be available (curl --man). Integration of
the manual is not required and a summary of the options will still be available
(curl --help). To integrate the manual your PATH is required to have
groff/nroff, perl and optionally gzip for compression.

Which causes build failure in the examples... or i'm an idiot.

1>sleepy_discord.vcxproj -> C:\Users\Brandan Lasley\Downloads\yourWaifu-sleepy-discord-703813e\Release\sleepy_discord.lib
2>------ Rebuild All started: Project: hello, Configuration: Release Win32 ------
3>------ Rebuild All started: Project: rock-paper-scissors, Configuration: Release Win32 ------
2>example0.cpp
3>main.cpp
2>LINK : fatal error LNK1181: cannot open input file 'libcurl_a.lib'
2>Done building project "hello.vcxproj" -- FAILED.
3>LINK : fatal error LNK1181: cannot open input file 'libcurl_a.lib'
3>Done building project "rock-paper-scissors.vcxproj" -- FAILED.
========== Rebuild All: 1 succeeded, 2 failed, 0 skipped ==========

Another Discord Crash in the destructor after network fault

On network fault which results in an exception thrown and you call the destructor of sleepy discord. Sleepy Discord will illegally access memory from another third party lib.

Example:

#include "sleepy_discord/websocketpp_websocket.h"

class ITNS_TIPBOT : public SleepyDiscord::DiscordClient {
public:
	using SleepyDiscord::DiscordClient::DiscordClient;
	void onMessage(SleepyDiscord::Message message) {}
};

int main()
{
	while (true)
	{
		try
		{
			ITNS_TIPBOT client("TOKEN", 2);
			client.run();
		} catch (...) // sleepy discord fix
		{
			
		}
	}
        return 0;
}

As soon as an exception is called it calls WebsocketppDiscordClient::~WebsocketppDiscordClient() which calls BaseDiscordClient::~BaseDiscordClient() which calls SleepyDiscord::Timer::stop() which calls implStop(); which calls WebsocketppDiscordClient::schedule -> timer->cancel();

This call stack then executes this line of code

std::size_t s = this->get_service().cancel(this->get_implementation(), ec);

Which calls this code

std::size_t cancel(implementation_type& impl, asio::error_code& ec)

Which calls this function

template <typename Time_Traits>
std::size_t win_iocp_io_context::cancel_timer(timer_queue<Time_Traits>& queue,
    typename timer_queue<Time_Traits>::per_timer_data& timer,
    std::size_t max_cancelled)
{
  // If the service has been shut down we silently ignore the cancellation.
  if (::InterlockedExchangeAdd(&shutdown_, 0) != 0)
    return 0;

  mutex::scoped_lock lock(dispatch_mutex_);
  op_queue<win_iocp_operation> ops;
  std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
  post_deferred_completions(ops);
  return n;
}

Which causes an memory violation.

Exception thrown: write access violation.
this was 0xDDDDDDDD.

Full call stack

TIPBOT.exe!asio::detail::win_iocp_io_context::cancel_timer<asio::detail::chrono_time_traits<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >(asio::detail::timer_queue<asio::detail::chrono_time_traits<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > & queue, asio::detail::timer_queue<asio::detail::chrono_time_traits<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >::per_timer_data & timer, unsigned int max_cancelled) Line 73	C++	Symbols loaded.

	TIPBOT.exe!asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >::cancel(asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >::implementation_type & impl, std::error_code & ec) Line 143	C++	Symbols loaded.
 	TIPBOT.exe!asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> >::cancel() Line 328	C++	Symbols loaded.
 	TIPBOT.exe!SleepyDiscord::WebsocketppDiscordClient::schedule::__l2::<lambda>() Line 69	C++	Symbols loaded.
 	[External Code]		Annotated Frame
 	TIPBOT.exe!SleepyDiscord::Timer::stop() Line 40	C++	Symbols loaded.
 	TIPBOT.exe!SleepyDiscord::BaseDiscordClient::~BaseDiscordClient() Line 38	C++	Symbols loaded.
 	TIPBOT.exe!SleepyDiscord::WebsocketppDiscordClient::~WebsocketppDiscordClient() Line 16	C++	Symbols loaded.
 	[External Code]		Annotated Frame
 	TIPBOT.exe!websocketpp::endpoint<websocketpp::connection<websocketpp::config::asio_tls_client>,websocketpp::config::asio_tls_client>::send(std::weak_ptr<void> hdl, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & payload, websocketpp::frame::opcode::value op) Line 178	C++	Symbols loaded.
 	TIPBOT.exe!SleepyDiscord::WebsocketppDiscordClient::send(std::basic_string<char,std::char_traits<char>,std::allocator<char> > message) Line 78	C++	Symbols loaded.
 	TIPBOT.exe!SleepyDiscord::BaseDiscordClient::sendL(std::basic_string<char,std::char_traits<char>,std::allocator<char> > message) Line 325	C++	Symbols loaded.
 	TIPBOT.exe!SleepyDiscord::BaseDiscordClient::sendHeartbeat() Line 441	C++	Symbols loaded.
 	TIPBOT.exe!SleepyDiscord::BaseDiscordClient::heartbeat() Line 436	C++	Symbols loaded.
 	[External Code]		Annotated Frame
 	TIPBOT.exe!SleepyDiscord::handleTimers(const std::error_code & ec, std::function<void __cdecl(void)> & code) Line 60	C++	Symbols loaded.
 	[External Code]		Annotated Frame
 	TIPBOT.exe!websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::handle_timer(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > __formal, std::function<void __cdecl(std::error_code const &)> callback, const std::error_code & ec) Line 735	C++	Symbols loaded.
 	[External Code]		Annotated Frame
 	TIPBOT.exe!asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &>,std::error_code>::operator()() Line 65	C++	Symbols loaded.
 	TIPBOT.exe!asio::asio_handler_invoke<asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &>,std::error_code> >(asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &>,std::error_code> & function, ...) Line 69	C++	Symbols loaded.
 	TIPBOT.exe!asio_handler_invoke_helpers::invoke<asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &>,std::error_code>,std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &> >(asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &>,std::error_code> & function, std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &> & context) Line 37	C++	Symbols loaded.
 	TIPBOT.exe!asio::detail::handler_work<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &>,asio::system_executor>::complete<asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &>,std::error_code> >(asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &>,std::error_code> & function, std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &> & handler) Line 81	C++	Symbols loaded.
 	TIPBOT.exe!asio::detail::wait_handler<std::_Binder<std::_Unforced,void (__thiscall websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::*)(std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > >,std::function<void __cdecl(std::error_code const &)>,std::error_code const &),websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config> *,std::shared_ptr<asio::basic_waitable_timer<std::chrono::steady_clock,asio::wait_traits<std::chrono::steady_clock> > > &,std::function<void __cdecl(std::error_code const &)> &,std::_Ph<1> const &> >::do_complete(void * owner, asio::detail::win_iocp_operation * base, const std::error_code & __formal, unsigned int __formal) Line 73	C++	Symbols loaded.
 	TIPBOT.exe!asio::detail::win_iocp_operation::complete(void * owner, const std::error_code & ec, unsigned int bytes_transferred) Line 46	C++	Symbols loaded.
 	TIPBOT.exe!asio::detail::win_iocp_io_context::do_one(unsigned long msec, std::error_code & ec) Line 420	C++	Symbols loaded.
 	TIPBOT.exe!asio::detail::win_iocp_io_context::run(std::error_code & ec) Line 162	C++	Symbols loaded.
 	TIPBOT.exe!asio::io_context::run() Line 61	C++	Symbols loaded.
 	TIPBOT.exe!websocketpp::transport::asio::endpoint<websocketpp::config::asio_tls_client::transport_config>::run() Line 615	C++	Symbols loaded.
 	TIPBOT.exe!SleepyDiscord::WebsocketppDiscordClient::run() Line 55	C++	Symbols loaded.
 	TIPBOT.exe!main() Line 24	C++	Symbols loaded.
 	[External Code]		Annotated Frame

Console:

[2018-04-11 15:25:55] [connect] Successful connection
[2018-04-11 15:25:55] [connect] WebSocket Connection 104.16.59.37:443 v-2 "WebSocket++/0.7.0" /?v=6 101
[2018-04-11 15:26:17] [error] handle_read_frame error: asio.system:1236 (The network connection was aborted by the local system.)
[2018-04-11 15:26:17] [info] asio async_shutdown error: asio.system:10054 (An existing connection was forcibly closed by the remote host.)
[2018-04-11 15:26:17] [disconnect] Disconnect close local:[1006,The network connection was aborted by the local system.] remote:[1006]

OS: Windows 10 Professional Build: 16299.309 64 bit
Compiler: Visual Studio 2017 Enterprise (MVSC 15.5.7)

updateStatus() fails with 4001 (Unknown opcode)

Calling updateStatus with any status argument in onReady or onMessage (just as a test) gives the following output:

[2018-02-11 12:19:24] [connect] Successful connection
[2018-02-11 12:19:24] [connect] WebSocket Connection 104.16.60.37:443 v-2 "WebSocket++/0.7.0" /?v=6 101
Ready!
[2018-02-11 12:19:25] [error] handle_read_frame error: asio.ssl.stream:1 (stream truncated)
[2018-02-11 12:19:25] [info] asio async_shutdown error: asio.ssl.stream:1 (stream truncated)
[2018-02-11 12:19:25] [disconnect] Disconnect close local:[1006,stream truncated] remote:[4001,Unknown opcode.]

Can be reproduced by adding callback like:
void onReady(std::string* jsonMsg) { updateStatus("some status"); }
into one of the examples.

Looking into the library code, it uses STATUS_UPDATE (3) when creating JSON message, which is still correct according to https://discordapp.com/developers/docs/topics/opcodes-and-status-codes#gateway-opcodes - so I'm not sure what's happening here.

sendMessage and other functions are working fine for me.

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.