Closed Technisha closed 4 years ago
Replace the handlers with {.async.}
, example proc (s: Shard, m: Message) {.async.}
. Also, if you do want to compress, install zlib1.so.1.
Thanks! I'll try it rn
Doesn't work ;-;
import dimscord, asyncdispatch, times
let cl = newDiscordClient("my token")
cl.events.on_ready = proc (s: Shard, r: Ready) = # Add Event Handler for on_ready.
echo "Connected to Discord as " & $r.user
cl.events.message_create = proc (s: Shard, m: Message) {.async.} = # Add Event Handler for message_create.
if m.author.bot: return
if m.content == "!ping": # if message content is "!ping"
let before = getTime().utc.toTime.toUnix
let msg = waitFor cl.api.sendMessage(m.channel_id, "ping?")
let after = getTime().utc.toTime.toUnix
asyncCheck cl.api.editMessage(m.channel_id, msg.id, "Pong! took " & $int(after - before) & "ms | " & $s.getPing() & "ms.") # Edit the message as pong! asyncCheck means that it will only raise an exception if it fails.
elif m.content == "!embed": # otherwise if content is embed
asyncCheck cl.api.sendMessage(m.channel_id, embed = ?Embed( # Sends a messge with embed. The '?' symbol is a shorthand for 'some' in options.
title: ?"Hello there!",
description: ?"This is a cool embed",
color: ?5))
waitFor cl.startSession()
Here is the error
/data/data/com.termux/files/home/nim_stuff/discord/main.nim(5, 22) Error: type mismatch: got <proc (s: Shard, r: Ready){.gcsafe, locks: 0.}> but expected 'proc (s: Shard, r: Ready): Future[system.void]{.closure.}'```
You forgot the ready proc one
Oh :P
It worked! Thanks! I'ma close this issue now (also i recommend fixing the example because it's kinda broken)
Heya, I'm having an issue trying to compile my code, here is the code: