Update modules.md#24
Conversation
| ```js | ||
| // Store Examples | ||
| const { Webpack } = BdApi; | ||
| const UserStore = Webpack.getStore("UserStore"); | ||
| const ChannelStore = Webpack.getStore("ChannelStore"); | ||
| const GuildStore = Webpack.getStore("GuildStore"); | ||
| const GuildChannelStore = Webpack.getStore("GuildChannelStore"); | ||
| const GuildMemberStore = Webpack.getStore("GuildMemberStore") | ||
|
|
||
| // Usage Examples | ||
| const currentUser = UserStore.getCurrentUser(); | ||
| // -> {id: "user_id", username: "UserName", discriminator: "1234", ...} | ||
|
|
||
| const allGuilds = GuildStore.getGuilds(); | ||
| // -> {guild_id_1: {name: "Guild Name 1", ...}, guild_id_2: {name: "Guild Name 2", ...}, ...} | ||
|
|
||
| const guildChannels = GuildChannelStore.getChannels("guild_id"); | ||
| // -> {id: "guild_id", count: number, VOCAL: {}, SELECTABLE: {}, ...} | ||
|
|
||
| const channel = ChannelStore.getChannel("channel_id"); | ||
| // -> {id: "channel_id", name: "Channel Name", type: "GUILD_TEXT", ...} | ||
|
|
||
| const isInGuild = GuildMemberStore.isMember("guild_id", currentUser.id); | ||
| // -> true or false | ||
|
|
||
| const guildRoles = GuildStore.getRoles("guild_id"); | ||
| // -> {role_id_1: {name: "Role Name 1", ...}, role_id_2: {name: "Role Name 2", ...}, ...} | ||
| ``` | ||
|
|
There was a problem hiding this comment.
This doesn't really seem relevant. Usage of getStore is documented on the API page already, right? Having some of the parameters there is nice, but they'd be more at home together with their methods below
There was a problem hiding this comment.
relevant is definitely the wrong term to use. It is quite literally examples of how to define the stores shown on that same page.
I see no issue with this
There was a problem hiding this comment.
The intent of this page is just to be a reference for the available stores and their methods, is it not? Those examples aren’t relevant for that purpose; it’s documented elsewhere how to use getStore. As it stands, this just seems like further padding in an already awkwardly formatted section of the docs
There was a problem hiding this comment.
I think having a small example here is fine. Ideally this would be combined with a link to a longer guide on using internal modules once it is written.
Full comprehensive list of all Stores and their methods().