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

cacheType change or implementation. #4365

Closed
ariesclark opened this issue Jun 17, 2020 · 2 comments · Fixed by #6013
Closed

cacheType change or implementation. #4365

ariesclark opened this issue Jun 17, 2020 · 2 comments · Fixed by #6013

Comments

@ariesclark
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Eg. I'm always frustrated when [...]

constructor(client, iterable, holds, cacheType = Collection, ...cacheOptions) {

cacheType = Collection

I don't see an easy way for changing the implementation used for Collections, as I'd like to implement my own way, this is a problem, and after asking on the Discord, I didn't find any existing methods or solutions aside from just directly overriding the methods.

Describe the ideal solution
A clear and concise description of what you want to happen.

Perhaps some form of way to declare the reference to a file or something, like in the options, that extends BaseCollection.

class Collection extends BaseCollection {

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

I've taken a look at directly forking Discord.js, but that'd be quickly unmaintainable, I've tried just going like client.users.cache.set = () => {} for example, but that's not friendly.

Additional context
Add any other context or screenshots about the feature request here.

@RDambrosio016
Copy link
Contributor

when implementing managers i specifically looked for an interface which easily allowed for dependency injection down the line, and its the whole reason why:

these arguments to basemanager are included

cacheType = Collection, ...cacheOptions

this is not hardcoded as collection

this.cache = new cacheType(...cacheOptions);

this is a thing

this.cacheType = cacheType;

However, with that being said, v12 was released before any thought of implementation for custom cache was done. The implementation should be relatively simple, just do something similar to structures.extend, managers grab the class which should be used, and feed that, plus additional optional arguments to BaseManager. However there were disagreements, some maintainers feel structures is already bad enough, and this would be even worse of an interface.

it could probably be done in a way that is not breaking, but i personally feel this is more of a v13 thing, and this will benefit a lot from typescript.

@ariesclark
Copy link
Author

ariesclark commented Jun 17, 2020

I don't think changing the cacheType will reliably work, because instances of it are created before I'm able to change the cacheType, but I'll need to take a further look.

And something like this would be lovely in v13 but v12 would be nice aswell.

@iCrawl iCrawl linked a pull request Jul 3, 2021 that will close this issue
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants