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()
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
Reference in New Issue