Struct serenity::model::id::ChannelId[][src]

pub struct ChannelId(pub u64);

An identifier for a Channel

Methods

impl ChannelId
[src]

Broadcasts that the current user is typing to a channel for the next 5 seconds.

After 5 seconds, another request must be made to continue broadcasting that the current user is typing.

This should rarely be used for bots, and should likely only be used for signifying that a long-running command is still being executed.

Note: Requires the Send Messages permission.

Examples

This example is not tested
use serenity::model::ChannelId;

let _successful = ChannelId(7).broadcast_typing();

Creates a permission overwrite for either a single Member or Role within the channel.

Refer to the documentation for GuildChannel::create_permission for more information.

Requires the Manage Channels permission.

React to a Message with a custom Emoji or unicode character.

Message::react may be a more suited method of reacting in most cases.

Requires the Add Reactions permission, if the current user is the first user to perform a react with a certain emoji.

Deletes this channel, returning the channel on a successful deletion.

Deletes a Message given its Id.

Refer to Message::delete for more information.

Requires the Manage Messages permission, if the current user is not the author of the message.

Deletes all messages by Ids from the given vector in the given channel.

Refer to the documentation for Channel::delete_messages for more information.

Requires the Manage Messages permission.

Note: Messages that are older than 2 weeks can't be deleted using this method.

Errors

Returns ModelError::BulkDeleteAmount if an attempt was made to delete either 0 or more than 100 messages.

Deletes all permission overrides in the channel from a member or role.

Note: Requires the Manage Channel permission.

Deletes the given Reaction from the channel.

Note: Requires the Manage Messages permission, if the current user did not perform the reaction.

Edits the settings of a Channel, optionally setting new values.

Refer to EditChannel's documentation for its methods.

Requires the Manage Channel permission.

Examples

Change a voice channel's name and bitrate:

This example is not tested
// assuming a `channel_id` has been bound

channel_id.edit(|c| c.name("test").bitrate(64000));

Edits a Message in the channel given its Id.

Message editing preserves all unchanged message data.

Refer to the documentation for EditMessage for more information regarding message restrictions and requirements.

Note: Requires that the current user be the author of the message.

Errors

Returns a ModelError::MessageTooLong if the content of the message is over the the limit, containing the number of unicode code points over the limit.

Deprecated since 0.5.8

: Use the to_channel_cached-method instead.

Search the cache for the channel with the Id.

Attempts to find a Channel by its Id in the cache.

Deprecated since 0.5.8

: Use the to_channel-method instead.

Search the cache for the channel. If it can't be found, the channel is requested over REST.

First attempts to find a Channel by its Id in the cache, upon failure requests it via the REST API.

Note: If the cache is not enabled, REST API will be used only.

Gets all of the channel's invites.

Requires the Manage Channels permission.

Gets a message from the channel.

Requires the Read Message History permission.

Gets messages from the channel.

Refer to Channel::messages for more information.

Requires the Read Message History permission.

Returns the name of whatever channel this id holds.

Pins a Message to the channel.

Gets the list of Messages which are pinned to the channel.

Gets the list of Users who have reacted to a Message with a certain Emoji.

Refer to Channel::reaction_users for more information.

Note: Requires the Read Message History permission.

Sends a message with just the given message content in the channel.

Errors

Returns a ModelError::MessageTooLong if the content of the message is over the above limit, containing the number of unicode code points over the limit.

Sends a file along with optional message contents. The filename must be specified.

Message contents may be passed by using the CreateMessage::content method.

The Attach Files and Send Messages permissions are required.

Note: Message contents must be under 2000 unicode code points.

Examples

Send files with the paths /path/to/file.jpg and /path/to/file2.jpg:

use serenity::model::id::ChannelId;

let channel_id = ChannelId(7);

let paths = vec!["/path/to/file.jpg", "path/to/file2.jpg"];

let _ = channel_id.send_files(paths, |m| m.content("a file"));

Send files using File:

use serenity::model::id::ChannelId;
use std::fs::File;

let channel_id = ChannelId(7);

let f1 = File::open("my_file.jpg").unwrap();
let f2 = File::open("my_file2.jpg").unwrap();

let files = vec![(&f1, "my_file.jpg"), (&f2, "my_file2.jpg")];

let _ = channel_id.send_files(files, |m| m.content("a file"));

Errors

If the content of the message is over the above limit, then a ClientError::MessageTooLong will be returned, containing the number of unicode code points over the limit.

Returns an HttpError::InvalidRequest(PayloadTooLarge) if the file is too large to send.

Sends a message to the channel.

Refer to the documentation for CreateMessage for more information regarding message restrictions and requirements.

Requires the Send Messages permission.

Note: Message contents must be under 2000 unicode code points.

Errors

Returns a ModelError::MessageTooLong if the content of the message is over the above limit, containing the number of unicode code points over the limit.

Unpins a Message in the channel given by its Id.

Requires the Manage Messages permission.

Retrieves the channel's webhooks.

Note: Requires the Manage Webhooks permission.

impl ChannelId
[src]

Retrieves the time that the Id was created at.

Immutably borrow inner Id.

Mutably borrow inner Id.

Trait Implementations

impl From<Channel> for ChannelId
[src]

Gets the Id of a Channel.

impl<'a> From<&'a Channel> for ChannelId
[src]

Gets the Id of a Channel.

impl From<PrivateChannel> for ChannelId
[src]

Gets the Id of a private channel.

impl<'a> From<&'a PrivateChannel> for ChannelId
[src]

Gets the Id of a private channel.

impl From<GuildChannel> for ChannelId
[src]

Gets the Id of a guild channel.

impl<'a> From<&'a GuildChannel> for ChannelId
[src]

Gets the Id of a guild channel.

impl Copy for ChannelId
[src]

impl Clone for ChannelId
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Default for ChannelId
[src]

Returns the "default value" for a type. Read more

impl Debug for ChannelId
[src]

Formats the value using the given formatter. Read more

impl Eq for ChannelId
[src]

impl Hash for ChannelId
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialOrd for ChannelId
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for ChannelId
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl AsRef<ChannelId> for ChannelId
[src]

Important traits for &'a mut R

Performs the conversion.

impl<'a> From<&'a ChannelId> for ChannelId
[src]

Performs the conversion.

impl From<u64> for ChannelId
[src]

Performs the conversion.

impl PartialEq for ChannelId
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl PartialEq<u64> for ChannelId
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Display for ChannelId
[src]

Formats the value using the given formatter. Read more

impl<'de> Deserialize<'de> for ChannelId
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Mentionable for ChannelId
[src]

Creates a mentionable string, that will be able to notify and/or create a link to the item. Read more

impl FromStr for ChannelId
[src]

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Auto Trait Implementations

impl Send for ChannelId

impl Sync for ChannelId