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

Modules abstraction is leaking #51

Open
2 of 3 tasks
neolectron opened this issue Sep 4, 2023 · 1 comment
Open
2 of 3 tasks

Modules abstraction is leaking #51

neolectron opened this issue Sep 4, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@neolectron
Copy link
Member

neolectron commented Sep 4, 2023

Problem

I've notices that even after the new module abstraction we still have to wire some of the stuff outside of the module.

to name a few :

Solution

To fix the leaky abstraction, we should allow users to provide this configuration within the scope of their module.

I'm keen into taking a shot at this next time I work on the bot.

@neolectron neolectron changed the title Fix leaking modules abstraction Modules abstraction is leaking and lack error-management. Sep 4, 2023
@neolectron neolectron changed the title Modules abstraction is leaking and lack error-management. Modules abstraction is leaking Sep 4, 2023
@neolectron
Copy link
Member Author

See #57 .

I think we will need sooner that I thought the module-creator.
Many benefits, one of them is you don't have to import the type BotModule anymore, and it will be far easier to pass something to a feature (especially if the thing passed to the feature depends on the module definition).

For now, I imagine something like :

export const myModule = createModule((ctx) => ({
  env: {
	MY_ENV_VAR: z.string().optionnal()
  },
  storage: {
  	channelList: z.string().array()
  },
  slashCommands: {/*...*/},
  eventHandlers: {
  	messageCreate: async () => {
		// Here I would be able to use ctx.env and ctx.storage
		console.log(ctx.storage.channelList) // typesafe + can be validated
  	}
  },
}));

@neolectron neolectron added the enhancement New feature or request label Sep 19, 2023
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