-
Notifications
You must be signed in to change notification settings - Fork 594
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
add support for edit_current_application endpoint #3035
base: next
Are you sure you want to change the base?
Conversation
f298296
to
424af70
Compare
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.
Use the provided to_vec function instead of importing it from serde_json.
Also you haven't added anything but the low level http interface? Http usually shouldn't be directly used and you should probably add a builder like how our other stuff interacts with http. |
424af70
to
0cee4cc
Compare
Pesky auto-import. Should be fixed now.
Right, so I'll make a |
It seems the |
5ba44d9
to
24ffd92
Compare
24ffd92
to
f2c1085
Compare
7f72d28
to
71ab298
Compare
20d45ab
to
8fd6b7e
Compare
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.
edit_current_appllication_info.rs -> edit_current_application_info.rs
8c6dd76
to
6a5d2a5
Compare
/// Interactions endpoint URL for the app. | ||
/// | ||
/// To update an Interactions endpoint URL via the API, the URL must be valid according | ||
/// to the [Receiving an Interaction] | ||
/// (https://discord.com/developers/docs/interactions/receiving-and-responding#receiving-an-interaction) documentation. |
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.
These docs are private and therefore unnecessary. I'd recommend instead incorporating them into the docs for the methods themselves.
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.
Ah, of course. Fixed it now.
6a5d2a5
to
8ed3e32
Compare
src/model/application/mod.rs
Outdated
pub terms_of_service_url: Option<FixedString>, | ||
pub bot: User, | ||
#[serde(default)] | ||
pub privacy_policy_url: Option<FixedString>, | ||
pub owner: Option<User>, | ||
// omitted `summary` because it deprecated | ||
pub verify_key: FixedString, | ||
pub terms_of_service_url: Option<String>, | ||
#[serde(default)] | ||
pub privacy_policy_url: Option<String>, | ||
#[serde(default)] | ||
pub owner: User, | ||
pub verify_key: String, | ||
pub team: Option<Team>, | ||
#[serde(default)] | ||
pub guild_id: Option<GuildId>, | ||
#[serde(default)] | ||
pub guild: Option<PartialGuild>, | ||
#[serde(default)] | ||
pub primary_sku_id: Option<SkuId>, | ||
#[serde(default)] | ||
pub slug: Option<FixedString>, | ||
pub slug: String, | ||
#[serde(default)] | ||
pub cover_image: Option<FixedString>, | ||
pub cover_image: String, | ||
#[serde(default)] | ||
pub flags: Option<ApplicationFlags>, | ||
#[serde(default)] | ||
pub tags: Option<Vec<String>>, | ||
pub approximate_guild_count: Option<u32>, | ||
#[serde(default)] | ||
pub install_params: Option<InstallParams>, | ||
pub approximate_user_install_count: Option<u32>, | ||
#[serde(default)] | ||
pub redirect_uris: Vec<String>, | ||
#[serde(default)] | ||
pub custom_install_url: Option<FixedString>, | ||
pub interactions_endpoint_url: Option<String>, | ||
/// The application's role connection verification entry point, which when configured will | ||
/// render the app as a verification method in the guild role verification configuration. | ||
pub role_connections_verification_url: Option<FixedString>, | ||
#[serde(default)] | ||
pub role_connections_verification_url: Option<String>, | ||
#[serde(default)] | ||
pub event_webhooks_url: Option<String>, | ||
pub event_webhook_status: EventWebhookStatus, | ||
#[serde(default)] | ||
pub event_webhook_type: Vec<EventWebhookType>, | ||
#[serde(default)] | ||
pub tags: Option<Vec<String>>, | ||
#[serde(default)] | ||
pub install_params: Option<InstallParams>, | ||
#[serde(default)] | ||
pub integration_types_config: HashMap<InstallationContext, InstallationContextConfig>, | ||
pub approximate_guild_count: Option<u32>, | ||
pub approximate_user_install_count: Option<u32>, | ||
pub guild: Option<PartialGuild>, | ||
pub redirect_uris: Option<Vec<String>>, | ||
pub interactions_endpoint_url: Option<String>, | ||
#[serde(default)] | ||
pub custom_install_url: String, |
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.
You have replaced a bunch of FixedString
here with String
, I'm assuming it's just a leftover from when this PR targeted current
, can you change it back to use FixedString
(for performance reasons).
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.
Yep, they were leftovers. I've changed them back to FixedString
now.
src/model/application/mod.rs
Outdated
impl InstallParams { | ||
#[must_use] | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
|
||
#[must_use] | ||
pub fn scopes(mut self, scopes: Vec<Scope>) -> Self { | ||
self.scopes = FixedArray::from_vec_trunc(scopes); | ||
self | ||
} | ||
|
||
#[must_use] | ||
pub fn permissions(mut self, permissions: Permissions) -> Self { | ||
self.permissions = permissions; | ||
self | ||
} | ||
} |
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.
Please make this an CreateInstallParams
in the new module to avoid mixing memory-optimised (FixedArray) and compute-optimised (Vec) types. This would also allow for new
to take both the required fields, scopes
and permissions
.
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.
Made the requested changes, I've also squashed the two commits since they're intertwined now.
pub fn icon(mut self, hash: &str) -> Self { | ||
if let Ok(image_hash) = hash.parse() { | ||
self.icon = Some(image_hash); | ||
} else { | ||
println!("Error parsing image hash while constructing EditCurrentApplicationInfo"); | ||
} | ||
self | ||
} | ||
|
||
/// Default rich presence invite cover image for the app. | ||
pub fn cover_image(mut self, hash: &str) -> Self { | ||
if let Ok(image_hash) = hash.parse() { | ||
self.cover_image = Some(image_hash); | ||
} else { | ||
println!("Error parsing image hash while constructing EditCurrentApplicationInfo"); | ||
} | ||
self | ||
} |
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.
- Please don't take types just to parse them into different types.
- Please don't print on the user's behalf.
- This is meant to be base64 image data, not an image hash, as the docs say.
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.
I've removed the unnecessary code and changed it to accept base64 data instead.
8ed3e32
to
52057ba
Compare
I think everything in |
4b7b8f0
to
e871454
Compare
e871454
to
d05677b
Compare
Fixes #2977