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

Implements changes to allow developers more control about event handling #2854

Open
wants to merge 122 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
062e685
Remove temporary `Vec` usage in the `http` module (#2624, #2646)
GnomedDev Dec 3, 2023
007c360
Remove deprecated items (#2645)
GnomedDev Dec 3, 2023
8df3f63
Remove more deprecated items (#2651)
GnomedDev Dec 8, 2023
651380e
Remove `*_arc` methods (#2654)
GnomedDev Dec 8, 2023
c564016
Clean up `ShardManager`/`ShardQueuer`/`ShardRunner` (#2653)
GnomedDev Dec 9, 2023
be79bdb
Put `Message::thread` behind a `Box` (#2658)
GnomedDev Dec 9, 2023
1526f9b
Replace `Vec` and `String` with `FixedArray` and `FixedString` for al…
GnomedDev Dec 10, 2023
2db8487
Fix truncation when using `FixedString<u8>` where multibyte character…
GnomedDev Dec 14, 2023
f20e8fc
Encode timestamps in RFC3339 (#2665)
Kerollmops Dec 22, 2023
686c5dc
Switch to `i64` in methods associated with `CreateCommandOption` (#2668)
ARandomDev99 Dec 22, 2023
b59131f
Get rid of the duplicate users cache (#2662)
GnomedDev Dec 28, 2023
916dd12
Change `Embed::fields` to use `FixedArray` (#2674)
GnomedDev Dec 28, 2023
eb0a598
Use `FixedArray` and `FixedString` in model enums (#2675)
GnomedDev Dec 28, 2023
5589be3
Bitpack boolean fields using fancy proc macro (#2673)
GnomedDev Dec 31, 2023
4e6d123
Use `nonmax::NonMax*` types in `Option`s wherever possible (#2681)
GnomedDev Jan 2, 2024
e92d095
Remove unused warning `#[allow(...)]`s (#2682)
GnomedDev Jan 2, 2024
22a8ec8
Get rid of `unsafe` (#2686)
GnomedDev Jan 3, 2024
613c04c
Swap Git dependencies for crates.io published versions (#2685)
GnomedDev Jan 3, 2024
ca917e1
Swap Id from `NonZero` to `NonMax` (#2689)
GnomedDev Jan 5, 2024
205ef79
Rewrite builders to take `Cow`s (#2688)
GnomedDev Jan 6, 2024
18298ac
Store `Request::params` as a slice instead of owning `ArrayVec` (#2694)
GnomedDev Jan 7, 2024
9697a72
Revert `Request::params` back to `Option` (#2695)
mkrasnitski Jan 7, 2024
918ab9b
Remove unnecessary `Vec` in `WsClient` (#2705)
GnomedDev Jan 10, 2024
e5c0b74
Feature gate `#[instrument]` macros (#2707)
GnomedDev Jan 10, 2024
a99e06b
Remove `impl Into<Option>` (#2701)
GnomedDev Jan 10, 2024
43e9b42
Get rid of `IntoIterator` generics wherever they are inefficent (#2698)
GnomedDev Jan 10, 2024
8b8f0d2
Clean up `Ratelimiter` (#2687)
GnomedDev Jan 10, 2024
79d87e7
Handle overflow checks in central locations (#2697)
GnomedDev Jan 10, 2024
28993ff
Shrink size and clean up `Error` (#2700)
GnomedDev Jan 10, 2024
49a4580
Remove manual `#[inline]` attributes (#2702)
GnomedDev Jan 10, 2024
a60d9f9
Remove `Into<*Id>` and `AsRef<str>` (#2704)
GnomedDev Jan 11, 2024
008dffc
Remove `Event::Unknown` variant (#2708)
mkrasnitski Jan 12, 2024
06c2c5e
Use `NonMax` to signal builder range constraints (#2703)
GnomedDev Jan 14, 2024
1407a28
Stop using `Value` in error parsing (#2710)
GnomedDev Jan 14, 2024
daa756d
Fix new clippy lints (#2713)
GnomedDev Jan 14, 2024
5cd9331
Update to `small-fixed-array` v0.2 (#2711)
GnomedDev Jan 14, 2024
2143cb2
Fix `@everyone` role deserialisation (#2716)
GnomedDev Jan 16, 2024
cbccc54
Fix `GuildChannel` deserialisation with `user_limit` (#2715)
GnomedDev Jan 16, 2024
3d1373a
Fix maximum description length to the correct size (#2718)
Milo123459 Jan 16, 2024
6ce84ed
Remove dashboard example (#2714)
GnomedDev Jan 16, 2024
2a8393f
Fix compilation from rebase
arqunis Jan 16, 2024
18724e9
Remove deprecated `absolute_ratelimits` feature (#2719)
GnomedDev Jan 16, 2024
98410d1
Implement `max_concurrency` support when starting shards (#2661)
mkrasnitski Jan 16, 2024
89f7d9c
Remove typemap without making everything generic (#2720)
GnomedDev Jan 16, 2024
de8a730
Provide `Arc<Data>` instead of `&Data` (#2722)
GnomedDev Jan 17, 2024
88af227
Add `Client::try_data` to fallibly fetch the data type (#2723)
GnomedDev Jan 18, 2024
a3ff024
Fix voice manager initialisation (#2727)
GnomedDev Jan 21, 2024
48fc5a1
Remove some pedantic lints from the whitelist (#2728)
mkrasnitski Jan 21, 2024
3c93108
Reduce unknown events to debug level, again (#2730)
GnomedDev Jan 21, 2024
e5ba9f8
Remove patch left in for `current` to stay non-breaking (#2732)
GnomedDev Jan 22, 2024
22b01f2
Fix compilation from rebase
arqunis Jan 22, 2024
23ade37
Fix testing example
mkrasnitski Jan 22, 2024
d927e16
Remove `PartialEq` implementations from all builders (#2734)
mkrasnitski Jan 22, 2024
f5e091f
Remove various instances of `impl AsRef<T>` (#2736)
GnomedDev Jan 24, 2024
4dac678
Remove `simd-json` support (#2735)
GnomedDev Jan 24, 2024
90f52b9
Fix massive code size of `client::dispatch` (#2739)
GnomedDev Jan 25, 2024
ed5336a
Fix RoleTags deserialisation after removal of simd-json (#2742)
GnomedDev Jan 26, 2024
5983bd9
Avoid cloning FullEvent in dispatch code (#2740)
GnomedDev Jan 27, 2024
234278b
Remove the builder trait and only take required arguments (#2741)
GnomedDev Jan 27, 2024
c98094c
Use Serializer::collect_seq in serialize impls (#2744)
GnomedDev Jan 28, 2024
a14480e
Convert enum number into wrapper struct to save type sizes (#2746)
GnomedDev Jan 29, 2024
db821e8
Use Arc<str> to store the token (#2745)
GnomedDev Jan 29, 2024
9f7a16c
Remove standard framework (#2731)
GnomedDev Jan 29, 2024
2b240da
Re-add Secret to bot token (#2748)
GnomedDev Jan 29, 2024
2afd573
Take Arc<Http> in ClientBuilder::new_with_http (#2749)
GnomedDev Feb 3, 2024
c0d4090
Remove duplicate content_safe implementation (#2759)
GnomedDev Feb 9, 2024
c91cdea
Simplify the message cache (#2757)
GnomedDev Feb 9, 2024
df125a6
Upgrade to small-fixed-array 0.4 (#2755)
GnomedDev Feb 9, 2024
6d08189
Avoid HashMap in ShardQueue (#2750)
GnomedDev Feb 11, 2024
b5ee23d
Switch to a generic type argument for `ClientBuilder::data` (#2765)
vicky5124 Feb 11, 2024
f5c0d09
Fix `VoiceServerUpdate::guild_id` being wrapped in `Option` (#2766)
GnomedDev Feb 13, 2024
350da4d
Improve MessageBuilder to fit with other builders (#2767)
GnomedDev Feb 15, 2024
a3a1226
Fill message cache with ChannelId::messages and ChannelId::pins (#2768)
GnomedDev Feb 15, 2024
bf1b35b
Defer deserialisation of Dispatch to handle errors (#2764)
GnomedDev Feb 16, 2024
f24e3cc
Remove duplicate `external_emojis` accessor (#2770)
wackbyte Feb 16, 2024
a9b4ebf
Remove `CreateAttachment::id` field (#2771)
mkrasnitski Feb 17, 2024
d5df025
Fix compilation from rebase
arqunis Mar 1, 2024
6179cab
Fix remaining clippy warnings
GnomedDev Mar 1, 2024
4c41fc1
Format unformatted code from rebase
arqunis Mar 1, 2024
a775f1d
Remove rebase artifacts in README
arqunis Mar 1, 2024
c710468
Synchronise README example from the `current` branch
arqunis Mar 1, 2024
c6dd011
Minor adjustments
mkrasnitski Mar 1, 2024
f002c9c
Apply Strum derives for FullEvent and Event (#2788)
cheesycod Mar 10, 2024
3f29665
Remove `Channel::name` (#2787)
GnomedDev Mar 10, 2024
36b9137
Use join_to_string throughout serenity (#2785)
GnomedDev Mar 10, 2024
826ac8f
Use ToArrayString for int -> str (#2786)
GnomedDev Mar 10, 2024
c2b97f8
Rename `unstable_discord_api` to `unstable` and disable it by default…
cheesycod Mar 10, 2024
9d9d0f2
Remove deprecated Channel::is_nsfw methods (#2792)
GnomedDev Mar 11, 2024
2283647
Replace manual Hash/Eq implementation on User/Role (#2793)
GnomedDev Mar 12, 2024
9b5ba29
Remove useless method wrappers (#2795)
GnomedDev Mar 13, 2024
dde4244
Fix unused variable warning from rebase
GnomedDev Mar 13, 2024
8f7831d
Remove deprecated mapped refs and Cache::channels (#2796)
GnomedDev Mar 13, 2024
d4bbc33
Use ExtractMap instead of HashMap when possible (#2797)
GnomedDev Mar 17, 2024
34fc824
Remove examples and inaccurate docs from HTTP (#2805)
GnomedDev Mar 17, 2024
5638ae9
Use NonMax in HTTP function signatures (#2803)
GnomedDev Mar 17, 2024
92750f5
Fix infinite loop in event deserialisation
arqunis Mar 19, 2024
551d005
Make Guild::shard_id follow additive features (#2813)
GnomedDev Mar 21, 2024
a818c36
Remove deprecated `Member` and `Guild` methods (#2817)
GnomedDev Mar 26, 2024
998ebae
Replace `CacheHttp` with `&Http` in more methods (#2818)
GnomedDev Mar 28, 2024
a9f08fc
Remove `serde_json::Value` from `Http` (#2806)
GnomedDev Mar 28, 2024
2b46d93
Add audit log reasons to remaining model methods (#2821)
GnomedDev Mar 29, 2024
7db18cd
Remove even more impl CacheHttp (#2822)
GnomedDev Mar 29, 2024
129337e
Remove `fs` feature for `tokio` by default (#2824)
UserIsntAvailable Mar 30, 2024
5a232a4
Update `reqwest` to v0.12 (#2826)
GnomedDev Apr 1, 2024
6f80311
Only include `cache::Settings::time_to_live` if temp cache is enabled…
GnomedDev Apr 3, 2024
7ace74b
Add resume_gateway_url support (#2832)
GnomedDev Apr 6, 2024
c3f8ca9
Correct documentation for `UserId::to_user` (#2809)
jamesbt365 Apr 9, 2024
ab8b4cc
Use CreateAttachment for EditGuild::banner (#2844)
NotNorom Apr 20, 2024
87345a0
Fix AuditLogEntry::user_id (#2846)
GnomedDev Apr 20, 2024
b213438
Restore match arm for `Error::Gateway` variant (#2847)
mkrasnitski Apr 22, 2024
3d50a65
Remove multiple event handler support (#2849)
GnomedDev Apr 24, 2024
6406655
Use RwLock for active collectors collection (#2851)
TheCataliasTNT2k Apr 26, 2024
8edab28
Provide old presence data from the cache on presence update (#2852)
jamesbt365 Apr 28, 2024
fe0f087
Allow filtering events before they are dispatched (#2853)
TheCataliasTNT2k Apr 28, 2024
f01fd2b
Remove permission checks (#2855)
jamesbt365 May 1, 2024
74659fc
Implement ToArrayString for Mention (#2857)
GnomedDev May 7, 2024
776185b
Add PartialGuild::greater_member_hierarchy + member_highest_role (#2856)
cheesycod May 8, 2024
e855379
Remove recently deprecated items
GnomedDev May 23, 2024
7f18f11
Update bool_to_bitflags to fix compilation without unstable
GnomedDev May 14, 2024
3e03891
Remove RUSTFLAGS from .cargo/config.toml (#2875)
jamesbt365 May 23, 2024
eb8495f
Remove deprecated link_ensured method (#2898)
GnomedDev Jun 10, 2024
bed49b1
Adds Framework::dispatch_automatically
TheCataliasTNT2k Apr 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .cargo/config.toml

This file was deleted.

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
47 changes: 17 additions & 30 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 @@ -131,9 +128,6 @@ jobs:
- name: Cache
uses: Swatinem/rust-cache@v2

- name: Remove cargo build config
run: rm .cargo/config.toml

- name: Build
run: cargo build

Expand Down Expand Up @@ -210,8 +204,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 +234,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
49 changes: 25 additions & 24 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.22.0" }
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.2" }
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 }
parking_lot = { version = "0.12.1"}
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.2", 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,38 +75,36 @@ 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"]
cache = ["fxhash", "dashmap"]
# Enables collectors, a utility feature that lets you await interaction events in code with
# zero setup, without needing to setup an InteractionCreate event listener.
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", "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"]

Loading
Loading