matterbridge/vendor/github.com/bwmarrin/discordgo/CONTRIBUTING.md

88 lines
3.8 KiB
Markdown
Raw Permalink Normal View History

# Getting started
To start off you can check out existing Pull Requests and Issues to get a gasp of what problems were currently solving and what features you can implement.
## Issues
Our issues are mostly used for bugs, however we welcome refactoring and conceptual issues.
Any other conversation would belong and would be moved into “Discussions”.
## Discussions
We use discussions for ideas, polls, announcements and help questions.
Dont hesitate to ask, we always would try to help.
## Pull Requests
If you want to help us by improving existing or adding new features, you create whats called a Pull Request (aka PR). It allows us to review your code, suggest changes and merge it.
Here are some tips on how to make a good first PR:
- When creating a PR, please consider a distinctive name and description for it, so the maintainers can understand what your PR changes / adds / removes.
- Its always a good idea to link documentation when implementing a new feature / endpoint
- If youre resolving an issue, dont forget to [link it](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) in the description.
- Enable the checkbox to allow maintainers to edit your PR and make commits in the PR branch when necessary.
- We may ask for changes, usually through suggestions or pull request comments. You can apply suggestions right in the UI. Any other change needs to be done manually.
- Dont forget to mark PR comments resolved when youre done applying the changes.
- Be patient and dont close and reopen your PR when no one responds, sometimes it might be held for a while. There might be a lot of reasons: release preparation, the feature is not significant, maintainers are busy, etc.
When your changes are still incomplete (i.e. in Work In Progress state), you can still create a PR, but consider making it a draft.
To make a draft PR, you can change the type of PR by clicking to a triangle next to the “Create Pull Request” button.
Once youre done, you can mark it as “Ready for review”, and well get right on it.
# Code style
To standardize and make things less messy we have a certain code style, that is persistent throughout the codebase.
## Naming
### REST methods
When naming a REST method, while it might seem counterintuitive, we specify the entity before the action verb (for GET endpoints we dont specify one however). Heres an example:
> Endpoint name: Get Channel Message
>
> Method name: `ChannelMessage`
> Endpoint name: Edit Channel Message
>
> Method name: `ChannelMessageEdit`
### Parameter structures
When making a complex REST endpoint, sometimes you might need to implement a `Param` structure. This structure contains parameters for certain endpoint/set of endpoints.
- If an endpoint/set of endpoints have mostly same parameters, its a good idea to use a single `Param` structure for them. Heres an example:
> Endpoint: `GuildMemberEdit`
>
> `Param` structure: `GuildMemberParams`
- If an endpoint/set of endpoints have differentiating parameters, `Param` structure can be named after the endpoints verb. Heres an example:
> Endpoint: `ChannelMessageSendComplex`
>
> `Param` structure: `MessageSend`
> Endpoint: `ChannelMessageEditComplex`
>
> `Param` structure: `MessageEdit`
### Events
When naming an event, we follow gateways internal naming (which often matches with the official event name in the docs). Heres an example:
> Event name: Interaction Create (`INTERACTION_CREATE`)
>
> Structure name: `InteractionCreate`
## Returns
In our REST functions we usually favor named returns instead of regular anonymous returns. This helps readability.
Additionally we try to avoid naked return statements for functions with a long body. Since its easier to loose track of the return result.