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

Tutorial #30

Closed
hgsipiere opened this issue Sep 11, 2020 · 8 comments
Closed

Tutorial #30

hgsipiere opened this issue Sep 11, 2020 · 8 comments

Comments

@hgsipiere
Copy link

A tutorial, explaining step by step the DSL would be nice.

@simmsb
Copy link
Owner

simmsb commented Sep 12, 2020

Hi, I've added some more content to the command docs: https://hackage.haskell.org/package/calamity-0.1.20.1/docs/Calamity-Commands-Dsl.html

If there's some part you're confused by please let me know.

@hgsipiere
Copy link
Author

hgsipiere commented Sep 12, 2020

Hi, so my understanding of Polysemy is that we want to run all our effects so we get rid of metrics with runMetricsNoop. When I do runDiNoop I seem to get an infinite loop, what am I doing wrong?
This is the project: https://github.com/hgsipiere/problem

Specifically this is the problematic line set:
void . P.runFinal . P.embedToFinal. D.runDiNoop . runCacheInMemory . runMetricsNoop . useConstantPrefix "!" $ runBotIO (BotToken token) $ do addCommands $ do helpCommand

It seems like DiPolysemy is logging, so I assume that's what to do if I want no logging.

@simmsb
Copy link
Owner

simmsb commented Sep 12, 2020

Hm, I compiled that project and everything works fine.

@hgsipiere
Copy link
Author

Hi sorry, it does work perfectly I was just confused. When I ran the calamity example, there seems to be logging without a run Di. If I wanted that level of logging and nothing extra (which I realise now is more than noop), what would you recommend?

@simmsb
Copy link
Owner

simmsb commented Sep 12, 2020

ah, I've forgotten to update calamity-example.

The project that's up to date is calamity-bot, you can see an example of usage here:
https://github.com/nitros12/calamity-bot/blob/master/src/CalamityBot.hs#L43

If you want to control the log level, use the filter function from di-core:
https://hackage.haskell.org/package/di-core-1.0.4/docs/Di-Core.html#v:filter

@hgsipiere
Copy link
Author

hgsipiere commented Sep 12, 2020

Ahh thank you, that sorted my problem. The other thing that I'm confused about is the ban example (https://hackage.haskell.org/package/calamity-0.1.20.1/docs/Calamity-Commands-Dsl.html ), my alternative was
void . invoke $ CreateGuildBan guild uid (CreateGuildBanData Nothing $ Just r). reason seems to conditionally implement the typeclass Request to give invoke from Calamity.HTTP.Reason; in this case it also doesn't complete the curried CreateGuildBan since it needs a GuildBanData. There is also another definition of reason as an AuditLogEntry constructor but that takes a Maybe Text which is a type mismatch I think.

The other things that I was confused about were guilds since the Discord UI calls them servers, snowflakes and what bot tokens were. These were just sorted from consulting the Discord API documentation (this clarified what deleteMessageDays are for as another example).

Is there a discord or irc for questions? An issue feels kind of inappropriate.

@simmsb
Copy link
Owner

simmsb commented Sep 12, 2020

the 'ban' example is incorrect and is missing the ban data yeah, the Calamity.HTTP.Reason.reason function is used to add the X-Audit-Log-Reason http header to the request, the 'reason' field of CreateGuildBanData is the correct way to attach the reason info for bans.

I'll push an update correcting that example in a bit.

I've made a guild for calamity here: https://discord.gg/NGCThCY

@hgsipiere
Copy link
Author

hgsipiere commented Sep 13, 2020 via email

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

2 participants