Struct serenity::model::GuildChannel [] [src]

pub struct GuildChannel {
    pub id: ChannelId,
    pub bitrate: Option<u64>,
    pub guild_id: GuildId,
    pub kind: ChannelType,
    pub last_message_id: Option<MessageId>,
    pub last_pin_timestamp: Option<String>,
    pub name: String,
    pub permission_overwrites: Vec<PermissionOverwrite>,
    pub position: i64,
    pub topic: Option<String>,
    pub user_limit: Option<u64>,
}

Represents a guild's voice or text channel. Some methods are available only for voice channels and some are only available for text channels.

Fields

Channel's Id. Default channel shares the Id with the guild it is in.

Bitrate of channel. Only available for voice channels.

Id of the guild the channel is located in.

Type of the channel.

The Id of last message sent. It lets client determine if channel has unread messages.

Timestamp of the latest pinned message.

Channel name. Voice and text channels have different limitations for this.

Permission overwrites for members and roles.

Position of a channel.

Text channel topic.

Max amount of members allowed in a voice channel.

Methods

impl GuildChannel
[src]

Marks the channel as being read up to a certain Message.

Refer to the documentation for rest::ack_message for more information.

Errors

If the cache is enabled, returns a ClientError::InvalidOperationAsBot if the current user is a bot user.

Broadcasts to the channel that the current user is typing.

For bots, this is a good indicator for long-running commands.

Note: Requires the Send Messages permission.

Errors

Returns a ClientError::InvalidPermissions if the current user does not have the required permissions.

Creates an invite leading to the given channel.

Examples

Create an invite that can only be used 5 times:

let invite = channel.create_invite(|i| i.max_uses(5));

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

Refer to the documentation for PermissionOverwrites for more information.

Requires the Manage Channels permission.

Examples

Creating a permission overwrite for a member by specifying the PermissionOverwrite::Member variant, allowing it the [Send Messages] permission, but denying the Send TTS Messages and Attach Files permissions:

use serenity::client::CACHE;
use serenity::model::{ChannelId, PermissionOverwrite, permissions};

let channel_id = 7;
let user_id = 8;

let allow = permissions::SEND_MESSAGES;
let deny = permissions::SEND_TTS_MESSAGES | permissions::ATTACH_FILES;
let overwrite = PermissionOverwrite {
    allow: allow,
    deny: deny,
    kind: PermissionOverwriteType::Member(user_id),
};

let cache = CACHE.read().unwrap();
let channel = cache.get_guild_channel(channel_id).unwrap();

let _ = channel.create_permission(overwrite);

Creating a permission overwrite for a role by specifying the PermissionOverwrite::Role variant, allowing it the Manage Webhooks permission, but denying the Send TTS Messages and Attach Files permissions:

use serenity::client::CACHE;
use serenity::model::{ChannelId, PermissionOverwrite, permissions};

let channel_id = 7;
let user_id = 8;

let allow = permissions::SEND_MESSAGES;
let deny = permissions::SEND_TTS_MESSAGES | permissions::ATTACH_FILES;
let overwrite = PermissionOverwrite {
    allow: allow,
    deny: deny,
    kind: PermissionOverwriteType::Member(user_id),
};

let cache = CACHE.read().unwrap();
let channel = cache.get_guild_channel(channel_id).unwrap();

let _ = channel.create_permission(overwrite);

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

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

Refer to Channel::delete_messages for more information.

Requires the Manage Messages permission.

Note: This uses bulk delete endpoint which is not available for user accounts.

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

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.

Modifies a channel's settings, such as its position or name.

Refer to EditChannels documentation for a full list of methods.

Examples

Change a voice channels name and bitrate:

channel.edit(|c| c.name("test").bitrate(86400));

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::get_messages for more information.

Requires the Read Message History permission.

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

Refer to Channel::get_reaction_users for more information.

Note: Requires the Read Message History permission.

Retrieves the channel's webhooks.

Note: Requires the Manage Webhooks permission.

Attempts to find this channel's guild in the Cache.

Note: Right now this performs a clone of the guild. This will be optimized in the future.

Pins a [Message] to the channel.

Gets all channel's pins.

Performs a search request for the channel's Messages.

Refer to the documentation for the Search builder for examples and more information.

Note: Bot users can not search.

Errors

If the cache is enabled, returns a ClientError::InvalidOperationAsBot if the current user is a bot.

Sends a message to the channel with the given content.

Note: This will only work when a Message is received.

Note: Requires the Send Messages permission.

Errors

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

Returns a ClientError::InvalidPermissions if the current user does not have the required permissions.

Unpins a Message in the channel given by its Id.

Requires the Manage Messages permission.

Trait Implementations

impl Display for GuildChannel
[src]

Formas the channel, creating a mention of it.

impl Clone for GuildChannel
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for GuildChannel
[src]

Formats the value using the given formatter.