Skip to content

Conversation

@aquarial
Copy link
Collaborator

@aquarial aquarial commented Sep 10, 2023

Populates the cache using the rest requests before the onStart handler. The cache example works unchanged:

-- from examples/cache.hs
  _ <- runDiscord $ def { discordToken = tok
                        , discordOnStart = do
                               cache <- readCache
                               liftIO $ putStrLn ("Cached info from gateway: " <> show cache)
                               stopDiscord
                        }

Comment on lines +23 to +26
FullApplication <$> o .: "id"
<*> o .: "name"
<*> o .: "flags"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be filled in later with all the fields https://discord.com/developers/docs/resources/application

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make a ticket for this?

@aquarial aquarial mentioned this pull request Sep 10, 2023
@L0neGamer
Copy link
Contributor

I'll admit, initially I wasn't on board with making an additional request at the beginning here. But now that I see we already do that, and don't use it to boot, I'm happier with this.

I am still a bit iffy on us using an MVar for the cache as I slightly fear that it won't be properly filled, however I think in this case it should be fine? we might be able to rejig it but it'll add complexity I think, and I'm not sure it's worth it in this case.

There's a couple other refactors that could be done here but I can do them after we merge.

@L0neGamer
Copy link
Contributor

The compilation failures are from not including the ApplicationInfo files in the cabal exposed-modules. Adding those makes it compile. I also ran the cache example and it works.

I think it would be worth mentioning in a comment somewhere what sort of data the cache will always have, and what sort of data it will only have if the cache is enabled (guild and channel info etc).

@L0neGamer
Copy link
Contributor

I'd be happy to approve this pending the ticket creation and a comment or two of documentation about when fields of the cache will be filled.

Comment on lines +23 to +26
FullApplication <$> o .: "id"
<*> o .: "name"
<*> o .: "flags"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make a ticket for this?

@aquarial
Copy link
Collaborator Author

User relevant changes:

  • The cache is now filled with user/application before the onStart handler
  • The cache now contains FullApplication instead of PartialApplication. Minor breaking change for things like the application command example

Fixes #186

@aquarial
Copy link
Collaborator Author

I'll update the cache doc in a few hours, gtg

@aquarial aquarial requested a review from L0neGamer September 11, 2023 03:08
Copy link
Contributor

@L0neGamer L0neGamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enough. If you see something else you want to change I'd request mentioning the setting for enabling the cache around the cache data structure documentation, but it should be fine.

Copy link
Contributor

@L0neGamer L0neGamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@aquarial aquarial merged commit 2250068 into master Sep 11, 2023
@aquarial aquarial deleted the cachestuff branch September 11, 2023 18:58
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

Successfully merging this pull request may close these issues.

3 participants