Remove debug, globalClient, and set clientUser in dispatch ready event
This commit is contained in:
parent
a38e361d54
commit
0c3f1d040c
|
@ -109,7 +109,6 @@ proc updateClientPresence*(client: DiscordClient, presence: Presence) {.async.}
|
||||||
"d": presence.presenceToJson()
|
"d": presence.presenceToJson()
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "payload:", jsonPayload
|
|
||||||
await client.sendGatewayRequest(jsonPayload)
|
await client.sendGatewayRequest(jsonPayload)
|
||||||
|
|
||||||
proc newDiscordClient(tkn: string): DiscordClient =
|
proc newDiscordClient(tkn: string): DiscordClient =
|
||||||
|
@ -121,8 +120,7 @@ proc newDiscordClient(tkn: string): DiscordClient =
|
||||||
var cac: Cache
|
var cac: Cache
|
||||||
new(cac)
|
new(cac)
|
||||||
|
|
||||||
result = DiscordClient(token: tkn, cache: cac)
|
result = DiscordClient(token: tkn, cache: cac, reconnecting: false)
|
||||||
globalDiscordClient = result
|
|
||||||
|
|
||||||
var tokenStream = newFileStream("token.txt", fmRead)
|
var tokenStream = newFileStream("token.txt", fmRead)
|
||||||
var tkn: string
|
var tkn: string
|
||||||
|
@ -136,7 +134,6 @@ var bot = newDiscordClient(tkn)
|
||||||
|
|
||||||
registerEventListener(EventType.evtReady, proc(bEvt: BaseEvent) =
|
registerEventListener(EventType.evtReady, proc(bEvt: BaseEvent) =
|
||||||
let event = ReadyEvent(bEvt)
|
let event = ReadyEvent(bEvt)
|
||||||
bot.clientUser = event.clientUser
|
|
||||||
|
|
||||||
echo "Ready! (v", nimcordMajor, ".", nimcordMinor, ".", nimcordMicro, ")"
|
echo "Ready! (v", nimcordMajor, ".", nimcordMinor, ".", nimcordMicro, ")"
|
||||||
echo "Logged in as: ", bot.clientUser.username, "#", bot.clientUser.discriminator
|
echo "Logged in as: ", bot.clientUser.username, "#", bot.clientUser.discriminator
|
||||||
|
|
|
@ -9,5 +9,6 @@ type DiscordClient* = ref object
|
||||||
heartbeatInterval*: int
|
heartbeatInterval*: int
|
||||||
heartbeatAcked*: bool
|
heartbeatAcked*: bool
|
||||||
lastSequence*: int
|
lastSequence*: int
|
||||||
|
endpoint*: string
|
||||||
var globalDiscordClient*: DiscordClient ## Global instance of the DiscordClient.
|
reconnecting*: bool
|
||||||
|
sessionID*: string
|
|
@ -51,7 +51,6 @@ type
|
||||||
## The ready event is triggered everytime the bot starts up.
|
## The ready event is triggered everytime the bot starts up.
|
||||||
## Stores the readyPayload (JSON Payload) that gets received and the bot's user.
|
## Stores the readyPayload (JSON Payload) that gets received and the bot's user.
|
||||||
readyPayload*: JsonNode
|
readyPayload*: JsonNode
|
||||||
clientUser*: User
|
|
||||||
|
|
||||||
# Channel Events
|
# Channel Events
|
||||||
|
|
||||||
|
|
Reference in New Issue