Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Comments

Add builder pattern for Instance#622

Merged
kozabrada123 merged 8 commits intodevfrom
api/instance-builder
Aug 12, 2025
Merged

Add builder pattern for Instance#622
kozabrada123 merged 8 commits intodevfrom
api/instance-builder

Conversation

@kozabrada123
Copy link
Member

@kozabrada123 kozabrada123 commented Jun 29, 2025

Adds a builder pattern for Instance - InstanceBuilder - which can be used to more precisely specify options before creating the Instance.

Adds the options to:

  • disable automatically detecting the software with with_software,
  • specify gateway options with with_gateway_options,
  • add default event observers with .default_gateway_events,
  • set default telemetry data (and telemetry sent in instance requests) with with_client_properties and
  • skip optional requests which may reveal we are using chorus (see Ensure maximum Discord-API mimickry #584) with skip_fetching_ratelimits, skip_fetching_general_info & skip_optional_requests

Replaces Instance::from_url_bundle with InstanceBuilder::build as the main Instance initialization method

Changes Instance::from_url_bundle and Instance::new to no longer have GatewayOptions as their 2nd argument (now you can specify that in InstanceBuilder, and that argument really had no place there.)

To update, change:

  • Instance::new("example.com", None) to Instance::new("example.com") or to InstanceBuilder::new("example.com".to_string()).build()
  • Instance::new("example.com", Some(options)) to InstanceBuilder::new("example.com".to_string()).with_gateway_options(options).build()
  • Instance::from_url_bundle(urls, None) to Instance::from_url_bundle(urls) or to InstanceBuilder::from_url_bundle(urls).build()
  • Instance::from_url_bundle(urls, Some(options)) to InstanceBuilder::from_url_bundle(urls).with_gateway_options(options).build()

@kozabrada123 kozabrada123 added Type: Enhancement Enhances an existing feature or behaviour. Type: Breaking Change labels Jun 29, 2025
- allows settings client properties that are used in Instance requests

- these are also passed down to new ChorusUsers
@kozabrada123 kozabrada123 marked this pull request as ready for review July 22, 2025 15:24
@kozabrada123 kozabrada123 merged commit b52303b into dev Aug 12, 2025
13 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Type: Breaking Change Type: Enhancement Enhances an existing feature or behaviour. Type: New Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant