Xh4H / Discord.jl

The Julia Discord API Wrapper
MIT License
152 stars 23 forks source link

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

Open jbytecode opened 2 months ago

jbytecode commented 2 months ago

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.