pub struct ChannelRest<'a> {
pub channel_id: Option<u64>,
pub guild_id: u64,
pub client: &'a RestClient,
}Fields§
§channel_id: Option<u64>§guild_id: u64§client: &'a RestClientImplementations§
Source§impl<'a> ChannelRest<'a>
impl<'a> ChannelRest<'a>
Sourcepub async fn create(
&self,
channel: Channel,
) -> Result<Channel, Box<dyn Error + Send + Sync>>
pub async fn create( &self, channel: Channel, ) -> Result<Channel, Box<dyn Error + Send + Sync>>
Examples found in repository?
examples/channel.rs (line 25)
5async fn main() {
6 pretty_env_logger::init();
7
8 let token = std::fs::read_to_string("token.txt").unwrap();
9
10 let client = RestClient::connect(token, None, None).await.unwrap();
11
12 println!("API Version: {}", client.api_version);
13
14 let guild_id: u64 = 1154763102554951811;
15
16 let channel = ChannelBuilder::default()
17 .name("test-channel")
18 .build()
19 .unwrap();
20
21 let mut channel = client
22 .guild(Some(guild_id))
23 .channel(None)
24 .unwrap()
25 .create(channel)
26 .await
27 .unwrap();
28
29 let channel_id = channel.id;
30 println!("Channel ID: {}", channel_id);
31
32 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
33
34 channel.name = Some("test-channel-edited".to_string());
35
36 client
37 .guild(Some(guild_id))
38 .channel(None)
39 .unwrap()
40 .edit(channel)
41 .await
42 .unwrap();
43 let invite = client
44 .guild(Some(guild_id))
45 .channel(Some(channel_id))
46 .unwrap()
47 .create_invite(Default::default())
48 .await
49 .unwrap();
50
51 println!("Invite: discord.gg/{}", invite.code);
52
53 let invite_count = client
54 .guild(Some(guild_id))
55 .channel(Some(channel_id))
56 .unwrap()
57 .get_invites()
58 .await
59 .unwrap()
60 .len();
61
62 println!("Invite count: {}", invite_count);
63
64 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
65
66 client
67 .guild(Some(guild_id))
68 .channel(Some(channel_id))
69 .unwrap()
70 .delete()
71 .await
72 .unwrap();
73}Sourcepub async fn edit(
&self,
channel: Channel,
) -> Result<Channel, Box<dyn Error + Send + Sync>>
pub async fn edit( &self, channel: Channel, ) -> Result<Channel, Box<dyn Error + Send + Sync>>
Examples found in repository?
examples/channel.rs (line 40)
5async fn main() {
6 pretty_env_logger::init();
7
8 let token = std::fs::read_to_string("token.txt").unwrap();
9
10 let client = RestClient::connect(token, None, None).await.unwrap();
11
12 println!("API Version: {}", client.api_version);
13
14 let guild_id: u64 = 1154763102554951811;
15
16 let channel = ChannelBuilder::default()
17 .name("test-channel")
18 .build()
19 .unwrap();
20
21 let mut channel = client
22 .guild(Some(guild_id))
23 .channel(None)
24 .unwrap()
25 .create(channel)
26 .await
27 .unwrap();
28
29 let channel_id = channel.id;
30 println!("Channel ID: {}", channel_id);
31
32 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
33
34 channel.name = Some("test-channel-edited".to_string());
35
36 client
37 .guild(Some(guild_id))
38 .channel(None)
39 .unwrap()
40 .edit(channel)
41 .await
42 .unwrap();
43 let invite = client
44 .guild(Some(guild_id))
45 .channel(Some(channel_id))
46 .unwrap()
47 .create_invite(Default::default())
48 .await
49 .unwrap();
50
51 println!("Invite: discord.gg/{}", invite.code);
52
53 let invite_count = client
54 .guild(Some(guild_id))
55 .channel(Some(channel_id))
56 .unwrap()
57 .get_invites()
58 .await
59 .unwrap()
60 .len();
61
62 println!("Invite count: {}", invite_count);
63
64 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
65
66 client
67 .guild(Some(guild_id))
68 .channel(Some(channel_id))
69 .unwrap()
70 .delete()
71 .await
72 .unwrap();
73}Sourcepub async fn delete(&self) -> Result<Channel, Box<dyn Error + Send + Sync>>
pub async fn delete(&self) -> Result<Channel, Box<dyn Error + Send + Sync>>
Examples found in repository?
examples/channel.rs (line 70)
5async fn main() {
6 pretty_env_logger::init();
7
8 let token = std::fs::read_to_string("token.txt").unwrap();
9
10 let client = RestClient::connect(token, None, None).await.unwrap();
11
12 println!("API Version: {}", client.api_version);
13
14 let guild_id: u64 = 1154763102554951811;
15
16 let channel = ChannelBuilder::default()
17 .name("test-channel")
18 .build()
19 .unwrap();
20
21 let mut channel = client
22 .guild(Some(guild_id))
23 .channel(None)
24 .unwrap()
25 .create(channel)
26 .await
27 .unwrap();
28
29 let channel_id = channel.id;
30 println!("Channel ID: {}", channel_id);
31
32 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
33
34 channel.name = Some("test-channel-edited".to_string());
35
36 client
37 .guild(Some(guild_id))
38 .channel(None)
39 .unwrap()
40 .edit(channel)
41 .await
42 .unwrap();
43 let invite = client
44 .guild(Some(guild_id))
45 .channel(Some(channel_id))
46 .unwrap()
47 .create_invite(Default::default())
48 .await
49 .unwrap();
50
51 println!("Invite: discord.gg/{}", invite.code);
52
53 let invite_count = client
54 .guild(Some(guild_id))
55 .channel(Some(channel_id))
56 .unwrap()
57 .get_invites()
58 .await
59 .unwrap()
60 .len();
61
62 println!("Invite count: {}", invite_count);
63
64 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
65
66 client
67 .guild(Some(guild_id))
68 .channel(Some(channel_id))
69 .unwrap()
70 .delete()
71 .await
72 .unwrap();
73}Sourcepub async fn create_invite(
&self,
create_channel_invite: CreateChannelInvite,
) -> Result<Invite, Box<dyn Error + Send + Sync>>
pub async fn create_invite( &self, create_channel_invite: CreateChannelInvite, ) -> Result<Invite, Box<dyn Error + Send + Sync>>
Examples found in repository?
examples/channel.rs (line 47)
5async fn main() {
6 pretty_env_logger::init();
7
8 let token = std::fs::read_to_string("token.txt").unwrap();
9
10 let client = RestClient::connect(token, None, None).await.unwrap();
11
12 println!("API Version: {}", client.api_version);
13
14 let guild_id: u64 = 1154763102554951811;
15
16 let channel = ChannelBuilder::default()
17 .name("test-channel")
18 .build()
19 .unwrap();
20
21 let mut channel = client
22 .guild(Some(guild_id))
23 .channel(None)
24 .unwrap()
25 .create(channel)
26 .await
27 .unwrap();
28
29 let channel_id = channel.id;
30 println!("Channel ID: {}", channel_id);
31
32 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
33
34 channel.name = Some("test-channel-edited".to_string());
35
36 client
37 .guild(Some(guild_id))
38 .channel(None)
39 .unwrap()
40 .edit(channel)
41 .await
42 .unwrap();
43 let invite = client
44 .guild(Some(guild_id))
45 .channel(Some(channel_id))
46 .unwrap()
47 .create_invite(Default::default())
48 .await
49 .unwrap();
50
51 println!("Invite: discord.gg/{}", invite.code);
52
53 let invite_count = client
54 .guild(Some(guild_id))
55 .channel(Some(channel_id))
56 .unwrap()
57 .get_invites()
58 .await
59 .unwrap()
60 .len();
61
62 println!("Invite count: {}", invite_count);
63
64 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
65
66 client
67 .guild(Some(guild_id))
68 .channel(Some(channel_id))
69 .unwrap()
70 .delete()
71 .await
72 .unwrap();
73}Sourcepub async fn get_invites(
&self,
) -> Result<Vec<Invite>, Box<dyn Error + Send + Sync>>
pub async fn get_invites( &self, ) -> Result<Vec<Invite>, Box<dyn Error + Send + Sync>>
Examples found in repository?
examples/channel.rs (line 57)
5async fn main() {
6 pretty_env_logger::init();
7
8 let token = std::fs::read_to_string("token.txt").unwrap();
9
10 let client = RestClient::connect(token, None, None).await.unwrap();
11
12 println!("API Version: {}", client.api_version);
13
14 let guild_id: u64 = 1154763102554951811;
15
16 let channel = ChannelBuilder::default()
17 .name("test-channel")
18 .build()
19 .unwrap();
20
21 let mut channel = client
22 .guild(Some(guild_id))
23 .channel(None)
24 .unwrap()
25 .create(channel)
26 .await
27 .unwrap();
28
29 let channel_id = channel.id;
30 println!("Channel ID: {}", channel_id);
31
32 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
33
34 channel.name = Some("test-channel-edited".to_string());
35
36 client
37 .guild(Some(guild_id))
38 .channel(None)
39 .unwrap()
40 .edit(channel)
41 .await
42 .unwrap();
43 let invite = client
44 .guild(Some(guild_id))
45 .channel(Some(channel_id))
46 .unwrap()
47 .create_invite(Default::default())
48 .await
49 .unwrap();
50
51 println!("Invite: discord.gg/{}", invite.code);
52
53 let invite_count = client
54 .guild(Some(guild_id))
55 .channel(Some(channel_id))
56 .unwrap()
57 .get_invites()
58 .await
59 .unwrap()
60 .len();
61
62 println!("Invite count: {}", invite_count);
63
64 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
65
66 client
67 .guild(Some(guild_id))
68 .channel(Some(channel_id))
69 .unwrap()
70 .delete()
71 .await
72 .unwrap();
73}Auto Trait Implementations§
impl<'a> Freeze for ChannelRest<'a>
impl<'a> !RefUnwindSafe for ChannelRest<'a>
impl<'a> Send for ChannelRest<'a>
impl<'a> Sync for ChannelRest<'a>
impl<'a> Unpin for ChannelRest<'a>
impl<'a> !UnwindSafe for ChannelRest<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more