krisppurg / dimscord

A Discord Bot & REST Library for Nim.
https://krisppurg.github.io/dimscord/
MIT License
222 stars 22 forks source link

Fixing and improving `helpers` #125

Open nayr7 opened 1 week ago

nayr7 commented 1 week ago

Abstract

This issue is to serve as a tracking list for issues related to the new helpers feature (bugs, library api, implementation details, ...).

Description

Each individual helpers must be thoroughly tested to ensure they work as intended and can be used correctly.

By order of priority, bugs should be fixed first, then we should seek to improve the api so that it's easier to read code that use them, and then the rest can come later.

Bug fixing

helpers/guild

helpers/message

helpers/user

helpers/channel

API Improvements

TODO

Implementation details

Reminder

Currently the helpers API rely on "magic" macros getClient and mainClient in order to access a user-made DiscordClient. This method has the benefit to avoid relying on global variables. The drawback is that we are at the mercy of the Nim's compiler evaluation order which can be brittle and unreliable and often throws the compile-time error "Client not registered' when the order is wrong. We use templates to defer evaluating the getClient generated symbol but this means implementing and testing helpers become harder since we have to watch out for template specific quirks. We should probably study a better way to do this internally.