Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The minimal example in the README.md is not working #45

Open
jbytecode opened this issue Aug 25, 2024 · 0 comments
Open

The minimal example in the README.md is not working #45

jbytecode opened this issue Aug 25, 2024 · 0 comments

Comments

@jbytecode
Copy link

jbytecode commented Aug 25, 2024

Hi,

The minimal example provided in the README.md

# Import Discord.jl.
using Discord
# Create a client.
c = Client("token"; presence=(game=(name="with Discord.jl", type=AT_GAME),))

# Create a handler for the MessageCreate event.
function handler(c::Client, e::MessageCreate)
    # Display the message contents.
    println("Received message: $(e.message.content)")
    # Add a reaction to the message.
    create(c, Reaction, e.message, '👍')
end

# Add the handler.
add_handler!(c, MessageCreate, handler)
# Log in to the Discord gateway.
open(c)
# Wait for the client to disconnect.
wait(c)

doesn't seem to be working (sure, I am replacing "token" with the real one). I am getting this chain of errors:

[ Info: Activating the current environment
  Activating project at `~/code/julia/bytie`
[ Info: Importing Discord
[ Info: Reading the DISCORD_TOKEN environment variable
[ Info: Creating Client
[ Info: Adding the handler
[ Info: Log into Discord
┌ Error: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx: error
│   (e, catch_backtrace()) =
│    TypeError: in IOWrapper, in T, expected T<:IO, got Type{HTTP.WebSockets.WebSocket}
│    Stacktrace:
│      [1] OpenTrick.IOWrapper(io::HTTP.WebSockets.WebSocket, c::Condition)
│        @ OpenTrick ~/.julia/packages/OpenTrick/l9e7p/src/OpenTrick.jl:11
│      [2] notifyreturn(c::Condition, x::HTTP.WebSockets.WebSocket)
│        @ OpenTrick ~/.julia/packages/OpenTrick/l9e7p/src/OpenTrick.jl:118
│      [3] (::OpenTrick.var"#5#7"{Condition})(stream::HTTP.WebSockets.WebSocket)
│        @ OpenTrick ~/.julia/packages/OpenTrick/l9e7p/src/OpenTrick.jl:51
│      [4] (::HTTP.WebSockets.var"#6#7"{Bool, Int64, Int64, OpenTrick.var"#5#7"{Condition}, String})(http::HTTP.Streams.Stream{HTTP.Messages.Response, HTTP.Connections.Connection{OpenSSL.SSLStream}})
│        @ HTTP.WebSockets ~/.julia/packages/HTTP/sJD5V/src/WebSockets.jl:378
│      [5] macro expansion
│        @ ~/.julia/packages/HTTP/sJD5V/src/clientlayers/StreamRequest.jl:65 [inlined]
│      [6] macro expansion

The similar example with the same exact DISCORD_TOKEN in Python is working so the the problem is not rooted at the API key.

Hope this issue will help improving the library.

Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant