Fix exception when trying to read from token file.

This commit is contained in:
SeanOMik 2020-05-31 01:14:56 -05:00
parent 6781ee5eea
commit ec8e41fa84
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
1 changed files with 3 additions and 1 deletions

View File

@ -100,10 +100,12 @@ proc startConnection*(client: DiscordClient) {.async.} =
e.msg = "Failed to get gateway url, token may of been incorrect!" e.msg = "Failed to get gateway url, token may of been incorrect!"
raise e raise e
var tokenStream = newFileStream("../token.txt", fmWrite) var tokenStream = newFileStream("token.txt", fmRead)
var tkn: string var tkn: string
if (not isNil(tokenStream)): if (not isNil(tokenStream)):
discard tokenStream.readLine(tkn) discard tokenStream.readLine(tkn)
echo "Read token from the file: ", tkn
tokenStream.close() tokenStream.close()
var bot = DiscordClient(token: tkn) var bot = DiscordClient(token: tkn)