Skip to content
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

Fix for media types in CreateAttachment to base64 conversion #2843

Closed
wants to merge 111 commits into from
Closed
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
c21dd23
Remove temporary `Vec` usage in the `http` module (#2624, #2646)
GnomedDev Dec 3, 2023
38ca4f8
Remove deprecated items (#2645)
GnomedDev Dec 3, 2023
32c7e88
Remove more deprecated items (#2651)
GnomedDev Dec 8, 2023
08ce162
Remove `*_arc` methods (#2654)
GnomedDev Dec 8, 2023
d8326a6
Clean up `ShardManager`/`ShardQueuer`/`ShardRunner` (#2653)
GnomedDev Dec 9, 2023
52ebc07
Put `Message::thread` behind a `Box` (#2658)
GnomedDev Dec 9, 2023
0bdcd73
Replace `Vec` and `String` with `FixedArray` and `FixedString` for al…
GnomedDev Dec 10, 2023
a6e25b3
Fix truncation when using `FixedString<u8>` where multibyte character…
GnomedDev Dec 14, 2023
abdb2d9
Encode timestamps in RFC3339 (#2665)
Kerollmops Dec 22, 2023
0bd4577
Switch to `i64` in methods associated with `CreateCommandOption` (#2668)
ARandomDev99 Dec 22, 2023
c206962
Get rid of the duplicate users cache (#2662)
GnomedDev Dec 28, 2023
ebbdc10
Change `Embed::fields` to use `FixedArray` (#2674)
GnomedDev Dec 28, 2023
6c3a3cf
Use `FixedArray` and `FixedString` in model enums (#2675)
GnomedDev Dec 28, 2023
e9833ab
Bitpack boolean fields using fancy proc macro (#2673)
GnomedDev Dec 31, 2023
65c21dc
Use `nonmax::NonMax*` types in `Option`s wherever possible (#2681)
GnomedDev Jan 2, 2024
819326e
Remove unused warning `#[allow(...)]`s (#2682)
GnomedDev Jan 2, 2024
8353f7c
Get rid of `unsafe` (#2686)
GnomedDev Jan 3, 2024
f94df9f
Swap Git dependencies for crates.io published versions (#2685)
GnomedDev Jan 3, 2024
abb1b92
Swap Id from `NonZero` to `NonMax` (#2689)
GnomedDev Jan 5, 2024
148f8d5
Rewrite builders to take `Cow`s (#2688)
GnomedDev Jan 6, 2024
76f076b
Store `Request::params` as a slice instead of owning `ArrayVec` (#2694)
GnomedDev Jan 7, 2024
a7a1f7f
Revert `Request::params` back to `Option` (#2695)
mkrasnitski Jan 7, 2024
050871d
Remove unnecessary `Vec` in `WsClient` (#2705)
GnomedDev Jan 10, 2024
118b836
Feature gate `#[instrument]` macros (#2707)
GnomedDev Jan 10, 2024
0c5dbaf
Remove `impl Into<Option>` (#2701)
GnomedDev Jan 10, 2024
6e52a32
Get rid of `IntoIterator` generics wherever they are inefficent (#2698)
GnomedDev Jan 10, 2024
46e0298
Clean up `Ratelimiter` (#2687)
GnomedDev Jan 10, 2024
50022cf
Handle overflow checks in central locations (#2697)
GnomedDev Jan 10, 2024
f1a2e18
Shrink size and clean up `Error` (#2700)
GnomedDev Jan 10, 2024
0bf8e03
Remove manual `#[inline]` attributes (#2702)
GnomedDev Jan 10, 2024
67b9280
Remove `Into<*Id>` and `AsRef<str>` (#2704)
GnomedDev Jan 11, 2024
c8e93c9
Remove `Event::Unknown` variant (#2708)
mkrasnitski Jan 12, 2024
f88d5bc
Use `NonMax` to signal builder range constraints (#2703)
GnomedDev Jan 14, 2024
65afebe
Stop using `Value` in error parsing (#2710)
GnomedDev Jan 14, 2024
23c37ee
Fix new clippy lints (#2713)
GnomedDev Jan 14, 2024
231e17a
Update to `small-fixed-array` v0.2 (#2711)
GnomedDev Jan 14, 2024
aef4580
Fix `@everyone` role deserialisation (#2716)
GnomedDev Jan 16, 2024
a0f49a4
Fix `GuildChannel` deserialisation with `user_limit` (#2715)
GnomedDev Jan 16, 2024
97cee94
Fix maximum description length to the correct size (#2718)
Milo123459 Jan 16, 2024
6d4ab4a
Remove dashboard example (#2714)
GnomedDev Jan 16, 2024
a41ffc3
Fix compilation from rebase
arqunis Jan 16, 2024
2775bce
Remove deprecated `absolute_ratelimits` feature (#2719)
GnomedDev Jan 16, 2024
9b3667f
Implement `max_concurrency` support when starting shards (#2661)
mkrasnitski Jan 16, 2024
4e7690d
Remove typemap without making everything generic (#2720)
GnomedDev Jan 16, 2024
75f56f0
Provide `Arc<Data>` instead of `&Data` (#2722)
GnomedDev Jan 17, 2024
5811327
Add `Client::try_data` to fallibly fetch the data type (#2723)
GnomedDev Jan 18, 2024
07c7b23
Fix voice manager initialisation (#2727)
GnomedDev Jan 21, 2024
86d489f
Remove some pedantic lints from the whitelist (#2728)
mkrasnitski Jan 21, 2024
3288dd6
Reduce unknown events to debug level, again (#2730)
GnomedDev Jan 21, 2024
57cdb8a
Remove patch left in for `current` to stay non-breaking (#2732)
GnomedDev Jan 22, 2024
2bc267e
Fix compilation from rebase
arqunis Jan 22, 2024
adfba3c
Fix testing example
mkrasnitski Jan 22, 2024
9a39e00
Remove `PartialEq` implementations from all builders (#2734)
mkrasnitski Jan 22, 2024
c2baebd
Remove various instances of `impl AsRef<T>` (#2736)
GnomedDev Jan 24, 2024
be11282
Remove `simd-json` support (#2735)
GnomedDev Jan 24, 2024
e3c0db4
Fix massive code size of `client::dispatch` (#2739)
GnomedDev Jan 25, 2024
748ecbb
Fix RoleTags deserialisation after removal of simd-json (#2742)
GnomedDev Jan 26, 2024
9e1a74e
Avoid cloning FullEvent in dispatch code (#2740)
GnomedDev Jan 27, 2024
c37ced6
Remove the builder trait and only take required arguments (#2741)
GnomedDev Jan 27, 2024
2d77617
Use Serializer::collect_seq in serialize impls (#2744)
GnomedDev Jan 28, 2024
baffcea
Convert enum number into wrapper struct to save type sizes (#2746)
GnomedDev Jan 29, 2024
51c320b
Use Arc<str> to store the token (#2745)
GnomedDev Jan 29, 2024
f9af5af
Remove standard framework (#2731)
GnomedDev Jan 29, 2024
4a6e907
Re-add Secret to bot token (#2748)
GnomedDev Jan 29, 2024
84963fc
Take Arc<Http> in ClientBuilder::new_with_http (#2749)
GnomedDev Feb 3, 2024
e196aa9
Fix breakage caused by rebase
GnomedDev Feb 9, 2024
90a8af6
Remove duplicate content_safe implementation (#2759)
GnomedDev Feb 9, 2024
62aeda2
Simplify the message cache (#2757)
GnomedDev Feb 9, 2024
74bba63
Upgrade to small-fixed-array 0.4 (#2755)
GnomedDev Feb 9, 2024
f364323
Avoid HashMap in ShardQueue (#2750)
GnomedDev Feb 11, 2024
ef6f161
Switch to a generic type argument for `ClientBuilder::data` (#2765)
vicky5124 Feb 11, 2024
2a6e1eb
Fix `VoiceServerUpdate::guild_id` being wrapped in `Option` (#2766)
GnomedDev Feb 13, 2024
a3f2903
Improve MessageBuilder to fit with other builders (#2767)
GnomedDev Feb 15, 2024
9215f52
Fill message cache with ChannelId::messages and ChannelId::pins (#2768)
GnomedDev Feb 15, 2024
0a40ff6
Defer deserialisation of Dispatch to handle errors (#2764)
GnomedDev Feb 16, 2024
8b19dca
Remove duplicate `external_emojis` accessor (#2770)
wackbyte Feb 16, 2024
5e5cea0
Remove `CreateAttachment::id` field (#2771)
mkrasnitski Feb 17, 2024
182422d
Fix compilation from rebase
arqunis Mar 1, 2024
36ebf7c
Fix remaining clippy warnings
GnomedDev Mar 1, 2024
5886866
Format unformatted code from rebase
arqunis Mar 1, 2024
913c926
Remove rebase artifacts in README
arqunis Mar 1, 2024
8f2e359
Synchronise README example from the `current` branch
arqunis Mar 1, 2024
8ca128b
Minor adjustments
mkrasnitski Mar 1, 2024
a89fe31
Apply Strum derives for FullEvent and Event (#2788)
cheesycod Mar 10, 2024
71ae842
Remove `Channel::name` (#2787)
GnomedDev Mar 10, 2024
14951f2
Use join_to_string throughout serenity (#2785)
GnomedDev Mar 10, 2024
c6c411c
Use ToArrayString for int -> str (#2786)
GnomedDev Mar 10, 2024
9ad9cd5
Rename `unstable_discord_api` to `unstable` and disable it by default…
cheesycod Mar 10, 2024
718078b
Remove deprecated Channel::is_nsfw methods (#2792)
GnomedDev Mar 11, 2024
94d2cf5
Replace manual Hash/Eq implementation on User/Role (#2793)
GnomedDev Mar 12, 2024
e44c3d4
Remove useless method wrappers (#2795)
GnomedDev Mar 13, 2024
dea3333
Fix unused variable warning from rebase
GnomedDev Mar 13, 2024
d9a5565
Remove deprecated mapped refs and Cache::channels (#2796)
GnomedDev Mar 13, 2024
aa9632e
Use ExtractMap instead of HashMap when possible (#2797)
GnomedDev Mar 17, 2024
1bedabc
Remove examples and inaccurate docs from HTTP (#2805)
GnomedDev Mar 17, 2024
5f5eb45
Use NonMax in HTTP function signatures (#2803)
GnomedDev Mar 17, 2024
b2e94a8
Fix infinite loop in event deserialisation
arqunis Mar 19, 2024
bc362df
Make Guild::shard_id follow additive features (#2813)
GnomedDev Mar 21, 2024
69c3cb8
Remove deprecated `Member` and `Guild` methods (#2817)
GnomedDev Mar 26, 2024
0479021
Replace `CacheHttp` with `&Http` in more methods (#2818)
GnomedDev Mar 28, 2024
6735aed
Remove `serde_json::Value` from `Http` (#2806)
GnomedDev Mar 28, 2024
6a9b659
Add audit log reasons to remaining model methods (#2821)
GnomedDev Mar 29, 2024
eac8dcc
Remove even more impl CacheHttp (#2822)
GnomedDev Mar 29, 2024
b613343
Remove `fs` feature for `tokio` by default (#2824)
UserIsntAvailable Mar 30, 2024
7665339
Update `reqwest` to v0.12 (#2826)
GnomedDev Apr 1, 2024
d973ccc
Only include `cache::Settings::time_to_live` if temp cache is enabled…
GnomedDev Apr 3, 2024
8de90dc
Add resume_gateway_url support (#2832)
GnomedDev Apr 6, 2024
95479f3
Correct documentation for `UserId::to_user` (#2809)
jamesbt365 Apr 9, 2024
482471d
Try to guess the media type for CreateAttachment
NotNorom Apr 18, 2024
1e7ba1e
Use CreateAttachment for EditGuild.banner()
NotNorom Apr 18, 2024
9d7dbcf
Add MediaType and use it for CreateAttachment construction
NotNorom Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
ci:
- .github/**/*
command_attr:
- command_attr/**/*
examples:
- examples/**/*
builder:
Expand Down
44 changes: 17 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
- no cache
- no gateway
- unstable Discord API features
- simd-json

include:
- name: beta
Expand All @@ -38,21 +37,19 @@ jobs:
- name: no default features
features: " "
- name: no cache
features: builder client framework gateway model http standard_framework utils rustls_backend
- name: simd-json
features: default_no_backend rustls_backend simd_json
features: builder client framework gateway model http utils rustls_backend
- name: no gateway
features: model http rustls_backend
- name: chrono
features: chrono
- name: unstable API + typesize
features: default unstable_discord_api typesize
features: default unstable typesize
dont-test: true
- name: builder without model
features: builder
dont-test: true
- name: unstable Discord API (no default features)
features: unstable_discord_api
features: unstable
dont-test: true

steps:
Expand Down Expand Up @@ -210,8 +207,7 @@ jobs:

- name: Build docs
run: |
cargo doc --no-deps --features collector,voice,unstable_discord_api
cargo doc --no-deps -p command_attr
cargo doc --no-deps --features collector,voice,unstable
env:
RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links

Expand Down Expand Up @@ -241,32 +237,26 @@ jobs:
- name: 'Check example 4'
run: cargo check -p e04_message_builder
- name: 'Check example 5'
run: cargo check -p e05_command_framework
run: cargo check -p e05_sample_bot_structure
- name: 'Check example 6'
run: cargo check -p e06_sample_bot_structure
run: cargo check -p e06_env_logging
- name: 'Check example 7'
run: cargo check -p e07_env_logging
run: cargo check -p e07_shard_manager
- name: 'Check example 8'
run: cargo check -p e08_shard_manager
- name: 'Check example 9'
run: cargo check -p e09_create_message_builder
run: cargo check -p e08_create_message_builder
- name: 'Check example 09'
run: cargo check -p e09_collectors
- name: 'Check example 10'
run: cargo check -p e10_collectors
run: cargo check -p e10_gateway_intents
- name: 'Check example 11'
run: cargo check -p e11_gateway_intents
run: cargo check -p e11_global_data
- name: 'Check example 12'
run: cargo check -p e12_global_data
run: cargo check -p e12_parallel_loops
- name: 'Check example 13'
run: cargo check -p e13_parallel_loops
run: cargo check -p e13_sqlite_database
- name: 'Check example 14'
run: cargo check -p e14_slash_commands
run: cargo check -p e14_message_components
- name: 'Check example 15'
run: cargo check -p e15_simple_dashboard
run: cargo check -p e15_webhook
- name: 'Check example 16'
run: cargo check -p e16_sqlite_database
- name: 'Check example 17'
run: cargo check -p e17_message_components
- name: 'Check example 18'
run: cargo check -p e18_webhook
- name: 'Check example 19'
run: cargo check -p e19_interactions_endpoint
run: cargo check -p e16_interactions_endpoint
1 change: 0 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
RUSTDOCFLAGS: --cfg docsrs -D warnings
run: |
cargo doc --no-deps --features full
cargo doc --no-deps -p command_attr

- name: Prepare docs
shell: bash -e -O extglob {0}
Expand Down
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ your code.

## Unsafe

Code that defines or uses `unsafe` functions must be reasoned with comments.
`unsafe` code can pose a potential for undefined behaviour related bugs and other
kinds of bugs to sprout if misused, weakening security. If you commit code containing
`unsafe`, you should confirm that its usage is necessary and correct.
Unsafe code is forbidden, and safe alternatives must be found. This can be mitigated by using
a third party crate to offload the burden of justifying the unsafe code, or finding a safe
alternative.

# Comment / Documentation style

Expand Down
45 changes: 23 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,40 @@ async-trait = "0.1.74"
tracing = { version = "0.1.40", features = ["log"] }
serde = { version = "1.0.192", features = ["derive"] }
url = { version = "2.4.1", features = ["serde"] }
tokio = { version = "1.34.0", features = ["fs", "macros", "rt", "sync", "time", "io-util"] }
tokio = { version = "1.34.0", features = ["macros", "rt", "sync", "time", "io-util"] }
futures = { version = "0.3.29", default-features = false, features = ["std"] }
dep_time = { version = "0.3.30", package = "time", features = ["formatting", "parsing", "serde-well-known"] }
base64 = { version = "0.21.5" }
secrecy = { version = "0.8.0", features = ["serde"] }
zeroize = { version = "1.7" } # Not used in serenity, but bumps the minimal version from secrecy
arrayvec = { version = "0.7.4", features = ["serde"] }
serde_cow = { version = "0.1.0" }
small-fixed-array = { version = "0.4", features = ["serde"] }
bool_to_bitflags = { version = "0.1.0" }
nonmax = { version = "0.5.5", features = ["serde"] }
strum = { version = "0.26", features = ["derive"] }
to-arraystring = "0.1.0"
extract_map = { version = "0.1.0", features = ["serde", "iter_mut"] }
# Optional dependencies
fxhash = { version = "0.2.1", optional = true }
simd-json = { version = "0.13.4", optional = true }
uwl = { version = "0.6.0", optional = true }
levenshtein = { version = "1.0.5", optional = true }
chrono = { version = "0.4.31", default-features = false, features = ["clock", "serde"], optional = true }
flate2 = { version = "1.0.28", optional = true }
reqwest = { version = "0.11.22", default-features = false, features = ["multipart", "stream"], optional = true }
static_assertions = { version = "1.1.0", optional = true }
reqwest = { version = "0.12.2", default-features = false, features = ["multipart", "stream", "json"], optional = true }
tokio-tungstenite = { version = "0.21.0", optional = true }
typemap_rev = { version = "0.3.0", optional = true }
bytes = { version = "1.5.0", optional = true }
percent-encoding = { version = "2.3.0", optional = true }
mini-moka = { version = "0.10.2", optional = true }
mime_guess = { version = "2.0.4", optional = true }
dashmap = { version = "5.5.3", features = ["serde"], optional = true }
parking_lot = { version = "0.12.1", optional = true }
ed25519-dalek = { version = "2.0.0", optional = true }
typesize = { version = "0.1.2", optional = true, features = ["url", "time", "serde_json", "secrecy", "dashmap", "parking_lot", "details"] }
typesize = { version = "0.1.6", optional = true, features = ["url", "time", "serde_json", "secrecy", "dashmap", "parking_lot", "nonmax", "extract_map_01", "details"] }
# serde feature only allows for serialisation,
# Serenity workspace crates
command_attr = { version = "0.5.1", path = "./command_attr", optional = true }
serenity-voice-model = { version = "0.2.0", path = "./voice-model", optional = true }

[dev-dependencies.http_crate]
version = "0.2.11"
version = "1.1.0"
package = "http"

[features]
Expand All @@ -74,13 +75,12 @@ default_no_backend = [
"gateway",
"model",
"http",
"standard_framework",
"utils",
]

# Enables builder structs to configure Discord HTTP requests. Without this feature, you have to
# construct JSON manually at some places.
builder = []
builder = ["tokio/fs"]
# Enables the cache, which stores the data received from Discord gateway to provide access to
# complete guild data, channels, users and more without needing HTTP requests.
cache = ["fxhash", "dashmap", "parking_lot"]
Expand All @@ -89,23 +89,22 @@ cache = ["fxhash", "dashmap", "parking_lot"]
collector = ["gateway", "model"]
# Wraps the gateway and http functionality into a single interface
# TODO: should this require "gateway"?
client = ["http", "typemap_rev"]
client = ["http"]
# Enables the Framework trait which is an abstraction for old-style text commands.
framework = ["client", "model", "utils"]
# Enables gateway support, which allows bots to listen for Discord events.
gateway = ["flate2"]
# Enables HTTP, which enables bots to execute actions on Discord.
http = ["mime_guess", "percent-encoding"]
http = ["dashmap", "parking_lot", "mime_guess", "percent-encoding"]
# Enables wrapper methods around HTTP requests on model types.
# Requires "builder" to configure the requests and "http" to execute them.
# Note: the model type definitions themselves are always active, regardless of this feature.
# TODO: remove dependeny on utils feature
model = ["builder", "http", "utils"]
voice_model = ["serenity-voice-model"]
standard_framework = ["framework", "uwl", "levenshtein", "command_attr", "static_assertions", "parking_lot"]
# Enables support for Discord API functionality that's not stable yet, as well as serenity APIs that
# are allowed to change even in semver non-breaking updates.
unstable_discord_api = []
unstable = []
# Enables some utility functions that can be useful for bot creators.
utils = []
voice = ["client", "model"]
Expand All @@ -117,16 +116,17 @@ chrono = ["dep:chrono", "typesize?/chrono"]

# This enables all parts of the serenity codebase
# (Note: all feature-gated APIs to be documented should have their features listed here!)
full = ["default", "collector", "unstable_discord_api", "voice", "voice_model", "interactions_endpoint"]

# Enables simd accelerated parsing.
simd_json = ["simd-json", "typesize?/simd_json"]
#
# Unstable functionality should be gated under the `unstable` feature.
full = ["default", "collector", "voice", "voice_model", "interactions_endpoint"]

# Enables temporary caching in functions that retrieve data via the HTTP API.
temp_cache = ["cache", "mini-moka", "typesize?/mini_moka"]

# Removed feature (https://github.com/serenity-rs/serenity/pull/2246)
absolute_ratelimits = []
typesize = ["dep:typesize", "small-fixed-array/typesize", "bool_to_bitflags/typesize"]

# Enables compile-time heavy instrument macros from tracing
tracing_instrument = ["tracing/attributes"]

# Backends to pick from:
# - Rustls Backends
Expand All @@ -147,3 +147,4 @@ native_tls_backend = [
[package.metadata.docs.rs]
features = ["full"]
rustdoc-args = ["--cfg", "docsrs"]