Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to API v9 and add support for threads (#1319)
This commit adds support to guild threads channels, see discord/discord-api-docs#2855. It also bumps the Discord API version and gateway to v9.
- Loading branch information
1 parent
13cf056
commit 4c53b48
Showing
20 changed files
with
1,043 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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,41 @@ | ||
use std::collections::HashMap; | ||
|
||
use crate::internal::prelude::*; | ||
use crate::model::channel::ChannelType; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub struct CreateThread(pub HashMap<&'static str, Value>); | ||
|
||
impl CreateThread { | ||
/// The name of the thread. | ||
/// | ||
/// **Note**: Must be between 2 and 100 characters long. | ||
pub fn name<D: ToString>(&mut self, name: D) -> &mut Self { | ||
self.0.insert("name", Value::String(name.to_string())); | ||
|
||
self | ||
} | ||
|
||
/// Duration in minutes to automatically archive the thread after recent activity. | ||
/// | ||
/// **Note**: Can only be set to 60, 1440, 4320, 10080 currently. | ||
pub fn auto_archive_duration(&mut self, duration: u16) -> &mut Self { | ||
self.0.insert("auto_archive_duration", Value::Number(Number::from(duration))); | ||
|
||
self | ||
} | ||
|
||
/// The thread type, which can be [`ChannelType::PublicThread`] or [`ChannelType::PrivateThread`]. | ||
/// | ||
/// **Note**: It defaults to [`ChannelType::PrivateThread`] in order to match the behavior when thread documentation was first published. | ||
/// This is a bit of a weird default though, and thus is highly likely to change in the future, | ||
/// so it is recommended to always explicitly setting it to avoid any breaking change. | ||
/// | ||
/// [`ChannelType::PublicThread`]: crate::model::channel::ChannelType::PublicThread | ||
/// [`ChannelType::PrivateThread`]: crate::model::channel::ChannelType::PrivateThread | ||
pub fn kind(&mut self, kind: ChannelType) -> &mut Self { | ||
self.0.insert("type", Value::Number(Number::from(kind as u8))); | ||
|
||
self | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.