Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: key not found: username #27

Open
jmcblane opened this issue May 29, 2019 · 2 comments
Open

Exception: key not found: username #27

jmcblane opened this issue May 29, 2019 · 2 comments

Comments

@jmcblane
Copy link

When trying the basic_bot example, I get a rather quick crash after a moment of the bot successfully working. Here is the output:

basic_bot.nim(19)        basic_bot
asyncdispatch.nim(1656)  waitFor
asyncdispatch.nim(1516)  poll
asyncdispatch.nim(1282)  runOnce
asyncdispatch.nim(191)   processPendingCallbacks
asyncmacro.nim(36)       sessionHandleSocketMessage_continue
discord.nim(354)         sessionHandleSocketMessageIter
asyncmacro.nim(313)      handleDispatch
asyncmacro.nim(36)       handleDispatch_continue
discord.nim(252)         handleDispatchIter
objects.nim(476)         newPresenceUpdate
json.nim(475)            []
tables.nim(165)          []
[[reraised from:
basic_bot.nim(19)        basic_bot
asyncdispatch.nim(1656)  waitFor
asyncdispatch.nim(1516)  poll
asyncdispatch.nim(1282)  runOnce
asyncdispatch.nim(191)   processPendingCallbacks
asyncfutures.nim(349)    :anonymous
]]
Error: unhandled exception: key not found: username
Async traceback:
  basic_bot.nim(19)       basic_bot
  asyncdispatch.nim(1656) waitFor
  asyncdispatch.nim(1516) poll
    ## Processes asynchronous completion events
  asyncdispatch.nim(1282) runOnce
  asyncdispatch.nim(191)  processPendingCallbacks
    ## Executes pending callbacks
  asyncmacro.nim(36)      sessionHandleSocketMessage_continue
    ## Resumes an async procedure
  discord.nim(354)        sessionHandleSocketMessageIter
  asyncmacro.nim(313)     handleDispatch
  asyncmacro.nim(36)      handleDispatch_continue
    ## Resumes an async procedure
  discord.nim(252)        handleDispatchIter
  objects.nim(476)        newPresenceUpdate
  json.nim(475)           []
  tables.nim(165)         []
Exception message: key not found: username
Exception type: [KeyError]

The key which is said to be not found changes from time to time. It has shown up as url, guild_id, and mostly shows up as username.

@krisppurg
Copy link

I've had that problem before, the user field in the PRESENCE_UPDATE payload only has the id field (unless the user has changed their discrim, avatar, name, etc) it has been fixed in the develop branch. the username and discriminator are now an Option type.

@Krognol
Copy link
Owner

Krognol commented Jul 20, 2019

I believe most (if not all) object fields should be Options on the develop branch. So try that instead for now.

My plans for now is to rewrite the whole library from scratch. I'm unsatisfied with more or less all of it, but to make it future proof I'm writing a JSON parser/marshaller that isn't stupid. I will make a separate branch for the updated library sometime soon and push progress there instead which will eventually replace the current master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants