Kraigie / nostrum

Elixir Discord Library
https://kraigie.github.io/nostrum/
MIT License
591 stars 125 forks source link

Multiple bots support #327

Open khionu opened 2 years ago

khionu commented 2 years ago

Problem

Nostrum's current design makes it very hard to have multiple bots running in the same BEAM runtime.

Solution

I'm going to take this problem into account with my refactor of #317, so no further architectural changes will be necessary. API changes however are unavoidable for this.

The simplest solution I can think of is a use macro that reimplements Nostrum.API on a user module, with the same API that Nostrum.API has currently. Then Nostrum.API.Internal can distinguish between bots based on constants generated by the use macro.

To the end user, the change then becomes this:

- result = Nostrum.API.api_function(args)
+ result = MyBots.BotAlpha.api_function(args)

A simple swap of which module is used.

sascha-wolf commented 1 year ago

Is this still on the roadmap? :)