Skip to content

All functions should be pure functions #2

@youcefs21

Description

@youcefs21

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions