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

All functions should be pure functions #2

Open
youcefs21 opened this issue Mar 12, 2022 · 0 comments
Open

All functions should be pure functions #2

youcefs21 opened this issue Mar 12, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@youcefs21
Copy link
Owner

The problem:

Currently, the bot is implemented in a manner that depends on global state, which can cause confusion, unexpected behaviour, and inconsistency.

The solution:

Switching to a more functional approach where the same input to a function always produces the same output would bring many benefits to reliability and improve development conditions

how to implement it:

Everywhere that calls on the global variables users or games should instead take in all the state it needs as function parameters.

Everywhere that writes to the global variables users or games should instead return the value instead

when it comes to buttons and views, you can't really return since all the work is being done by a callback function being called within the discord api wrapper. Instead edit the object's attributes and access them when the view has stopped

@youcefs21 youcefs21 added the enhancement New feature or request label Mar 12, 2022
@youcefs21 youcefs21 self-assigned this Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant