Remove debug, globalClient, and set clientUser in dispatch ready event

This commit is contained in:
SeanOMik 2020-06-22 00:22:48 -05:00
parent a38e361d54
commit 0c3f1d040c
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
3 changed files with 4 additions and 7 deletions

View File

@ -109,7 +109,6 @@ proc updateClientPresence*(client: DiscordClient, presence: Presence) {.async.}
"d": presence.presenceToJson()
}
echo "payload:", jsonPayload
await client.sendGatewayRequest(jsonPayload)
proc newDiscordClient(tkn: string): DiscordClient =
@ -121,8 +120,7 @@ proc newDiscordClient(tkn: string): DiscordClient =
var cac: Cache
new(cac)
result = DiscordClient(token: tkn, cache: cac)
globalDiscordClient = result
result = DiscordClient(token: tkn, cache: cac, reconnecting: false)
var tokenStream = newFileStream("token.txt", fmRead)
var tkn: string
@ -136,7 +134,6 @@ var bot = newDiscordClient(tkn)
registerEventListener(EventType.evtReady, proc(bEvt: BaseEvent) =
let event = ReadyEvent(bEvt)
bot.clientUser = event.clientUser
echo "Ready! (v", nimcordMajor, ".", nimcordMinor, ".", nimcordMicro, ")"
echo "Logged in as: ", bot.clientUser.username, "#", bot.clientUser.discriminator

View File

@ -9,5 +9,6 @@ type DiscordClient* = ref object
heartbeatInterval*: int
heartbeatAcked*: bool
lastSequence*: int
var globalDiscordClient*: DiscordClient ## Global instance of the DiscordClient.
endpoint*: string
reconnecting*: bool
sessionID*: string

View File

@ -51,7 +51,6 @@ type
## The ready event is triggered everytime the bot starts up.
## Stores the readyPayload (JSON Payload) that gets received and the bot's user.
readyPayload*: JsonNode
clientUser*: User
# Channel Events