-
-
Notifications
You must be signed in to change notification settings - Fork 252
fix: Embed::addField off-by-one (26th field accepted) + centralised payload limits #1470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Refaltor77
wants to merge
3
commits into
discord-php:master
Choose a base branch
from
Refaltor77:fix/embed-addfield-off-by-one-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /* | ||
| * This file is a part of the DiscordPHP project. | ||
| * | ||
| * Copyright (c) 2015-2022 David Cole <david.cole1340@gmail.com> | ||
| * Copyright (c) 2020-present Valithor Obsidion <valithor@discordphp.org> | ||
| * | ||
| * This file is subject to the MIT license that is bundled | ||
| * with this source code in the LICENSE.md file. | ||
| */ | ||
|
|
||
| namespace Discord\Helpers; | ||
|
|
||
| /** | ||
| * Centralises Discord API payload size limits as shared constants. | ||
| * | ||
| * Classes that produce or validate Discord-bound payloads implement this | ||
| * interface to expose consistent limits in a single location. Grouping | ||
| * them prevents the "magic number" drift that happens when the same | ||
| * limit is repeated across builders and parts. | ||
| * | ||
| * @link https://docs.discord.com/developers/resources/message#embed-object-embed-limits | ||
| * @link https://docs.discord.com/developers/resources/message#create-message | ||
| * | ||
| * @since 10.48.0 | ||
| */ | ||
| interface ValidatesDiscordLimits | ||
| { | ||
| /** Maximum characters in an embed title. */ | ||
| public const EMBED_TITLE_MAX = 256; | ||
|
|
||
| /** Maximum characters in an embed description. */ | ||
| public const EMBED_DESCRIPTION_MAX = 4096; | ||
|
|
||
| /** Maximum characters in an embed author name. */ | ||
| public const EMBED_AUTHOR_NAME_MAX = 256; | ||
|
|
||
| /** Maximum characters in an embed footer text. */ | ||
| public const EMBED_FOOTER_TEXT_MAX = 2048; | ||
|
|
||
| /** Maximum characters in an embed field name. */ | ||
| public const EMBED_FIELD_NAME_MAX = 256; | ||
|
|
||
| /** Maximum characters in an embed field value. */ | ||
| public const EMBED_FIELD_VALUE_MAX = 1024; | ||
|
|
||
| /** Maximum number of fields in an embed. */ | ||
| public const EMBED_FIELDS_MAX = 25; | ||
|
|
||
| /** Maximum combined characters across all embed text fields. */ | ||
| public const EMBED_TOTAL_CHARS_MAX = 6000; | ||
|
|
||
| /** Maximum characters in a message content field. */ | ||
| public const MESSAGE_CONTENT_MAX = 2000; | ||
|
|
||
| /** Maximum embeds attached to a single message. */ | ||
| public const MESSAGE_EMBEDS_MAX = 10; | ||
|
|
||
| /** Maximum file attachments on a single message. */ | ||
| public const MESSAGE_FILES_MAX = 10; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some values are duplicated, if you're just going for naming, add both into 1 or add a function that calls the same value. |
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong type of file (the interface itself); In php, if you don't know, there are other types of "classes" like
TraitsorEnum's - please use the proper one.