Skip to content

Update modules.md#24

Merged
zerebos merged 4 commits intoBetterDiscord:mainfrom
DaddyBoard:main
Dec 2, 2024
Merged

Update modules.md#24
zerebos merged 4 commits intoBetterDiscord:mainfrom
DaddyBoard:main

Conversation

@DaddyBoard
Copy link
Copy Markdown
Member

Full comprehensive list of all Stores and their methods().

Comment thread docs/discord/modules.md
Comment on lines +6 to +34
```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", ...}, ...}
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@zerebos zerebos merged commit 8bb0252 into BetterDiscord:main Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants