KnightHacks / scythe

A Command-Driven Discord.js Addon
MIT License
3 stars 3 forks source link

Add Storage Provider(s) #11

Open suneettipirneni opened 3 years ago

suneettipirneni commented 3 years ago

Adds an abstract interface for storage I like how other libraries have done this, and we can copy verbatim if needed. Basically it takes the guild ID as paratemeters for it's functions and provides persistent state per-guild.

Akairo-Discord: https://github.com/discord-akairo/discord-akairo/blob/master/src/providers/MongooseProvider.js

Commando: https://github.com/discordjs/Commando/blob/master/src/providers/sqlite.js

rob-3 commented 3 years ago

I agree we need a storage mechanism. I suggest writing a StorageProvider class with a simple get(key: string): any and set(key: string, value: any) and then we can make it into an interface or abstract class later if we need multiple storage implementations. We can handle per-Guild storage by prepending the guildID to the keys and then we can expose partially applied functions so Command authors don't have to worry about dealing with guild scoping.