Skip to content
This repository has been archived by the owner on Aug 28, 2020. It is now read-only.

Proposal: Non overriding events #432

Closed
1 task done
ShayBox opened this issue Sep 22, 2018 · 4 comments · Fixed by #696
Closed
1 task done

Proposal: Non overriding events #432

ShayBox opened this issue Sep 22, 2018 · 4 comments · Fixed by #696
Labels
Mod: Loader Issues and PRs related to the loader. Type: Caching Issues and PRs related to caching. Type: Question Issues that do not belong to the Issue Tracker and should be asked in the official Discord Server.

Comments

@ShayBox
Copy link
Contributor

ShayBox commented Sep 22, 2018

Describe your proposal

An event option to prevent an event from overriding the built-in core event if provided.

Use-Cases for your proposal

You could have both the core event functional, and a personal event without one being overridden.

Expected and actual behavior

An event with the option override: false will not override a core event.

Further details

By default all events's override option would default to true, to keep the current functionality the same and not break things, and allow users to create events that do not override core events, Ex.
The core message event working
A personal message event with override: false, doing something completely different than the core event.

This keeps the core events in-framework, keeps them up to date with the framework, rather than having to require users to copy all the code from events they need access to into their events then keep that code up to date, when they never modify the code in the first place.

Another possible configuration would be, Ex.
A message event with override: true (default) that overrides the core event, that you would copy and modify the core event's code into, to modify the functionality,
Then allow you to add a second event with override: false that has an entirely different use, doesn't contain the core event code or any variant, and both of them function.

  • This (as described) doesn't include any breaking changes.
@bdistin
Copy link
Contributor

bdistin commented Sep 22, 2018

You can already have non-overriding events, so long as the name is different from core. Event#name is by default the name of the file, Event#event is by default the Event#name. But you can name the file differently, and set Event#event back to the intended event. Events are stored in the EventStore by name, so that's why events with the same name overwrite each other.

The only way to make this proposal really work the way I think you want it to work would be by renaming the core pieces away from their base event name, and setting their event option back to the event name they are supposed to handle, which would be breaking for all those who have transferred events to overwrite core functionality.

I am not opposed to that breaking change, but if we do that, we would need a predictable naming scheme. Do you have any suggestions?

@kyranet kyranet added Type: Question Issues that do not belong to the Issue Tracker and should be asked in the official Discord Server. Type: Caching Issues and PRs related to caching. Mod: Loader Issues and PRs related to the loader. labels Sep 22, 2018
@kyranet
Copy link
Contributor

kyranet commented Sep 22, 2018

Maybe we should make this a little more clear in the guides, as they have no mention of it.

@kyranet
Copy link
Contributor

kyranet commented Nov 6, 2018

With #475 we're starting to prefix core events with core to prevent any naming conflict, so you can have per-say a guildCreate event handler separate of the built-in one without naming it differently to prevent the conflict. The changes will be applied to all events with or after the settings (#425).

This is a breaking change, however, as if the override was intentional, they'll need to rename and set the constructor to point to the right event.

@ShayBox
Copy link
Contributor Author

ShayBox commented Aug 13, 2019

Going to close this as it's been merged

@ShayBox ShayBox closed this as completed Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Mod: Loader Issues and PRs related to the loader. Type: Caching Issues and PRs related to caching. Type: Question Issues that do not belong to the Issue Tracker and should be asked in the official Discord Server.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants