aegis.cpp
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Friends | List of all members
aegis::channel Class Reference

Class for performing actions pertaining to a specified channel. More...

#include <channel.hpp>

Public Member Functions

 channel (const snowflake channel_id, const snowflake guild_id, core *_bot, asio::io_context &_io, ratelimit::ratelimit_mgr &_ratelimit)
 Constructor for the channel object. More...
 
guildget_guild () const
 Get a reference to the guild object this channel belongs to. More...
 
guildget_guild (std::error_code &ec) const noexcept
 Get a reference to the guild object this channel belongs to. More...
 
std::string get_name () const noexcept
 Get channel name. More...
 
gateway::objects::channel::channel_type get_type () const noexcept
 Get the type of this channel. More...
 
permission perms () const noexcept
 Get bot's permission for this channel. More...
 
aegis::future
< gateway::objects::message
create_message (const std::string &content, int64_t nonce=0)
 Send message to this channel. More...
 
aegis::future
< gateway::objects::message
create_message (create_message_t obj)
 Send message to this channel. More...
 
aegis::future
< gateway::objects::message
create_message_embed (const std::string &content, const json &embed, int64_t nonce=0)
 Send an embed message to this channel. More...
 
aegis::future
< gateway::objects::message
create_message_embed (create_message_t obj)
 Send an embed message to this channel. More...
 
aegis::future
< gateway::objects::message
get_message (snowflake message_id)
 Get message from this channel. More...
 
aegis::future
< gateway::objects::messages
get_messages (get_messages_t obj)
 Get multiple messages from this channel. More...
 
aegis::future
< gateway::objects::message
edit_message (snowflake message_id, const std::string &content)
 Edit a message in this channel. More...
 
aegis::future
< gateway::objects::message
edit_message (edit_message_t obj)
 Edit a message in this channel. More...
 
aegis::future
< gateway::objects::message
edit_message_embed (snowflake message_id, const std::string &content, const json &embed)
 Edit an embed message in this channel. More...
 
aegis::future
< gateway::objects::message
edit_message_embed (edit_message_t obj)
 Edit an embed message in this channel. More...
 
aegis::future< rest::rest_replydelete_message (snowflake message_id)
 Delete a message. More...
 
aegis::future< rest::rest_replybulk_delete_message (const std::vector< int64_t > &messages)
 Delete up to 100 messages at once. More...
 
aegis::future< rest::rest_replybulk_delete_message (const std::vector< snowflake > &messages)
 Delete up to 100 messages at once. More...
 
aegis::future
< gateway::objects::channel
modify_channel (lib::optional< std::string > _name={}, lib::optional< int > _position={}, lib::optional< std::string > _topic={}, lib::optional< bool > _nsfw={}, lib::optional< int > _bitrate={}, lib::optional< int > _user_limit={}, lib::optional< std::vector< gateway::objects::permission_overwrite >> _permission_overwrites={}, lib::optional< snowflake > _parent_id={}, lib::optional< int > _rate_limit_per_user={})
 Modify this channel (all parameters optional) More...
 
aegis::future
< gateway::objects::channel
modify_channel (modify_channel_t obj)
 Modify this channel (all parameters optional) More...
 
aegis::future< rest::rest_replydelete_channel ()
 Delete this channel. More...
 
aegis::future< rest::rest_replycreate_reaction (snowflake message_id, const std::string &emoji_text)
 Add new reaction on message. More...
 
aegis::future< rest::rest_replycreate_reaction (create_reaction_t obj)
 Add new reaction on message. More...
 
aegis::future< rest::rest_replydelete_own_reaction (snowflake message_id, const std::string &emoji_text)
 Delete own reaction on message. More...
 
aegis::future< rest::rest_replydelete_own_reaction (delete_own_reaction_t obj)
 Delete own reaction on message. More...
 
aegis::future< rest::rest_replydelete_user_reaction (snowflake message_id, const std::string &emoji_text, snowflake member_id)
 Delete specified member reaction on message. More...
 
aegis::future< rest::rest_replydelete_user_reaction (delete_user_reaction_t obj)
 Delete specified member reaction on message. More...
 
aegis::future< rest::rest_replyget_reactions (snowflake message_id, const std::string &emoji_text)
 Get all reactions for this message. More...
 
aegis::future< rest::rest_replyget_reactions (get_reactions_t obj)
 Get all reactions for this message. More...
 
aegis::future< rest::rest_replydelete_all_reactions (snowflake message_id)
 Delete all reactions by message. More...
 
aegis::future< rest::rest_replyedit_channel_permissions (snowflake _overwrite_id, int64_t _allow, int64_t _deny, const std::string &_type)
 Edit channel permission override. More...
 
aegis::future< rest::rest_replyedit_channel_permissions (edit_channel_permissions_t obj)
 Edit channel permission override. More...
 
aegis::future< rest::rest_replyget_channel_invites ()
 Get active channel invites. More...
 
aegis::future< rest::rest_replycreate_channel_invite (const lib::optional< int > max_age, const lib::optional< int > max_uses, const lib::optional< bool > temporary, const lib::optional< bool > unique)
 Create a new channel invite. More...
 
aegis::future< rest::rest_replycreate_channel_invite (create_channel_invite_t obj)
 Create a new channel invite. More...
 
aegis::future< rest::rest_replydelete_channel_permission (snowflake overwrite_id)
 Delete channel permission override. More...
 
aegis::future< rest::rest_replytrigger_typing_indicator ()
 Trigger typing indicator in channel (lasts 10 seconds) More...
 
aegis::future< rest::rest_replyget_pinned_messages ()
 Get pinned messages in channel. More...
 
aegis::future< rest::rest_replyadd_pinned_channel_message (snowflake message_id)
 Add a pinned message in channel. More...
 
aegis::future< rest::rest_replydelete_pinned_channel_message (snowflake message_id)
 Delete a pinned message in channel. More...
 
aegis::future< rest::rest_replygroup_dm_add_recipient (snowflake user_id)
 Add member to a group direct message. More...
 
aegis::future< rest::rest_replygroup_dm_remove_recipient (snowflake user_id)
 Remove member from a group direct message. More...
 
aegis::channelget_parent () const
 Get parent channel. More...
 
aegis::snowflake get_parent_id () const noexcept
 Get parent channel snowflake. More...
 
snowflake get_id () const noexcept
 Get the aegis::snowflake of this channel. More...
 
snowflake get_guild_id () const noexcept
 Get the snowflake of this channel's guild - 0 if DM. More...
 
bool is_dm () const noexcept
 Is this channel a DM or in a guild. More...
 
shared_mutex & mtx () const noexcept
 Get the mutex for the channel. More...
 
bool nsfw () const noexcept
 Get if this channel is set to NSFW. More...
 

Friends

class guild
 
class core
 

Detailed Description

Class for performing actions pertaining to a specified channel.

Constructor & Destructor Documentation

aegis::channel::channel ( const snowflake  channel_id,
const snowflake  guild_id,
core _bot,
asio::io_context &  _io,
ratelimit::ratelimit_mgr _ratelimit 
)

Constructor for the channel object.

Parameters
channel_idSnowflake of this channel
guild_idSnowflake of guild this channel belongs to
_botPointer to the core lib instance
_ioReference to asio::io_context for the bot
ratelimitReference to bucket factory that manages rate limits for this channel

Member Function Documentation

aegis::future< rest::rest_reply > aegis::channel::add_pinned_channel_message ( snowflake  message_id)

Add a pinned message in channel.

Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::bulk_delete_message ( const std::vector< int64_t > &  messages)

Delete up to 100 messages at once.

Parameters
messageVector of up to 100 message int64_t to delete
Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::bulk_delete_message ( const std::vector< snowflake > &  messages)

Delete up to 100 messages at once.

Parameters
messageVector of up to 100 message snowflakes to delete
Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::create_channel_invite ( const lib::optional< int >  max_age,
const lib::optional< int >  max_uses,
const lib::optional< bool >  temporary,
const lib::optional< bool >  unique 
)

Create a new channel invite.

Parameters
max_ageHow long this invite code lasts for in seconds
max_usesThe max uses this invite code allows
temporaryIs this invite code temporary
uniqueIs this invite code a unique one-use
Returns
aegis::future<rest::rest_reply>
aegis::future<rest::rest_reply> aegis::channel::create_channel_invite ( create_channel_invite_t  obj)

Create a new channel invite.

See also
aegis::create_channel_invite_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<rest::rest_reply>
aegis::future< gateway::objects::message > aegis::channel::create_message ( const std::string &  content,
int64_t  nonce = 0 
)

Send message to this channel.

Parameters
contentA string of the message to send
Returns
aegis::future<gateway::objects::message>
aegis::future< aegis::gateway::objects::message > aegis::channel::create_message ( create_message_t  obj)

Send message to this channel.

See also
aegis::create_message_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<gateway::objects::message>
aegis::future< gateway::objects::message > aegis::channel::create_message_embed ( const std::string &  content,
const json &  embed,
int64_t  nonce = 0 
)

Send an embed message to this channel.

Deprecated:
Parameters
contentA string of the message to send
embedA json object of the embed object itself
Returns
aegis::future<gateway::objects::message>
aegis::future< gateway::objects::message > aegis::channel::create_message_embed ( create_message_t  obj)

Send an embed message to this channel.

Deprecated:
See also
aegis::create_message_embed_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<gateway::objects::message>
aegis::future< rest::rest_reply > aegis::channel::create_reaction ( snowflake  message_id,
const std::string &  emoji_text 
)

Add new reaction on message.

Parameters
message_idSnowflake of message
emoji_textText of emoji being added name:snowflake
Returns
aegis::future<rest::rest_reply>
aegis::future<rest::rest_reply> aegis::channel::create_reaction ( create_reaction_t  obj)

Add new reaction on message.

See also
aegis::create_reaction_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::delete_all_reactions ( snowflake  message_id)

Delete all reactions by message.

Parameters
message_idSnowflake of message
Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::delete_channel ( )

Delete this channel.

Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::delete_channel_permission ( snowflake  overwrite_id)

Delete channel permission override.

Parameters
overwrite_idSnowflake of the channel permission to delete
Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::delete_message ( snowflake  message_id)

Delete a message.

Parameters
message_idSnowflake of the message to delete
Returns
aegis::future<rest::rest_reply>

can delete your own messages freely - provide separate function or keep history of messages? message::delete() can determine if author is bot for self-delete

aegis::future< rest::rest_reply > aegis::channel::delete_own_reaction ( snowflake  message_id,
const std::string &  emoji_text 
)

Delete own reaction on message.

Parameters
message_idSnowflake of message
emoji_textText of emoji being added name:snowflake
Returns
aegis::future<rest::rest_reply>
aegis::future<rest::rest_reply> aegis::channel::delete_own_reaction ( delete_own_reaction_t  obj)

Delete own reaction on message.

See also
aegis::delete_own_reaction_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::delete_pinned_channel_message ( snowflake  message_id)

Delete a pinned message in channel.

Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::delete_user_reaction ( snowflake  message_id,
const std::string &  emoji_text,
snowflake  member_id 
)

Delete specified member reaction on message.

Parameters
message_idSnowflake of message
emoji_textText of emoji being added name:snowflake
member_idSnowflake of member to remove emoji from
Returns
aegis::future<rest::rest_reply>
aegis::future<rest::rest_reply> aegis::channel::delete_user_reaction ( delete_user_reaction_t  obj)

Delete specified member reaction on message.

See also
aegis::delete_user_reaction_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::edit_channel_permissions ( snowflake  _overwrite_id,
int64_t  _allow,
int64_t  _deny,
const std::string &  _type 
)

Edit channel permission override.

Parameters
_overwrite_idSnowflake of the permission override
_allowInt64 allow flags
_denyInt64 deny flags
_typeType of override (role/user)
Returns
aegis::future<rest::rest_reply>
aegis::future<rest::rest_reply> aegis::channel::edit_channel_permissions ( edit_channel_permissions_t  obj)

Edit channel permission override.

See also
aegis::edit_channel_permissions_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<rest::rest_reply>
aegis::future< gateway::objects::message > aegis::channel::edit_message ( snowflake  message_id,
const std::string &  content 
)

Edit a message in this channel.

Parameters
message_idSnowflake of the message to replace. Must be your own message
contentA string of the message to set
Returns
aegis::future<gateway::objects::message>
aegis::future< gateway::objects::message > aegis::channel::edit_message ( edit_message_t  obj)

Edit a message in this channel.

See also
aegis::edit_message_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<gateway::objects::message>
aegis::future< gateway::objects::message > aegis::channel::edit_message_embed ( snowflake  message_id,
const std::string &  content,
const json &  embed 
)

Edit an embed message in this channel.

Deprecated:
Parameters
message_idSnowflake of the message to replace. Must be your own message
contentA string of the message to set
embedA json object of the embed object itself
Returns
aegis::future<gateway::objects::message>
aegis::future< gateway::objects::message > aegis::channel::edit_message_embed ( edit_message_t  obj)

Edit an embed message in this channel.

Deprecated:
See also
aegis::edit_message_embed_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<gateway::objects::message>
aegis::future< rest::rest_reply > aegis::channel::get_channel_invites ( )

Get active channel invites.

Returns
aegis::future<rest::rest_reply>
guild & aegis::channel::get_guild ( ) const

Get a reference to the guild object this channel belongs to.

Exceptions
aegis::exceptionThrown on failure.
Returns
Reference to the guild this channel belongs to
guild & aegis::channel::get_guild ( std::error_code &  ec) const
noexcept

Get a reference to the guild object this channel belongs to.

Returns
Reference to the guild this channel belongs to
snowflake aegis::channel::get_guild_id ( ) const
noexcept

Get the snowflake of this channel's guild - 0 if DM.

Returns
A snowflake of this channel's guild
snowflake aegis::channel::get_id ( ) const
noexcept

Get the aegis::snowflake of this channel.

Returns
An aegis::snowflake of the channel
aegis::future< gateway::objects::message > aegis::channel::get_message ( snowflake  message_id)

Get message from this channel.

Parameters
message_idSnowflake of the message to retrieve
Returns
aegis::future<gateway::objects::message>
aegis::future< gateway::objects::messages > aegis::channel::get_messages ( get_messages_t  obj)

Get multiple messages from this channel.

See also
aegis::get_messages_t
Parameters
objStruct of the request
Returns
aegis::future<gateway::objects::messages>
std::string aegis::channel::get_name ( ) const
noexcept

Get channel name.

Returns
String of channel name
aegis::channel* aegis::channel::get_parent ( ) const

Get parent channel.

Returns
aegis::channel
aegis::snowflake aegis::channel::get_parent_id ( ) const
noexcept

Get parent channel snowflake.

Returns
aegis::snowflake
aegis::future< rest::rest_reply > aegis::channel::get_pinned_messages ( )

Get pinned messages in channel.

Returns
aegis::future<rest::rest_reply>
aegis::future< rest::rest_reply > aegis::channel::get_reactions ( snowflake  message_id,
const std::string &  emoji_text 
)

Get all reactions for this message.

Parameters
message_idSnowflake of message
emoji_textText of emoji being added name:snowflake
Returns
aegis::future<rest::rest_reply>
Todo:

Support query parameters

before[snowflake], after[snowflake], limit[int]

aegis::future<rest::rest_reply> aegis::channel::get_reactions ( get_reactions_t  obj)

Get all reactions for this message.

See also
aegis::get_reactions_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<rest::rest_reply>
gateway::objects::channel::channel_type aegis::channel::get_type ( ) const
noexcept

Get the type of this channel.

Returns
An channel_type enum for this channel
aegis::future< rest::rest_reply > aegis::channel::group_dm_add_recipient ( snowflake  user_id)

Add member to a group direct message.

Returns
aegis::future<rest::rest_reply>
Todo:
Will likely move to aegis class requires OAuth permissions to perform
aegis::future< rest::rest_reply > aegis::channel::group_dm_remove_recipient ( snowflake  user_id)

Remove member from a group direct message.

Returns
aegis::future<rest::rest_reply>
Todo:
Will likely move to aegis class requires OAuth permissions to perform
bool aegis::channel::is_dm ( ) const
noexcept

Is this channel a DM or in a guild.

Returns
bool whether channel is a DM or belongs to a guild
aegis::future< gateway::objects::channel > aegis::channel::modify_channel ( lib::optional< std::string >  _name = {},
lib::optional< int >  _position = {},
lib::optional< std::string >  _topic = {},
lib::optional< bool >  _nsfw = {},
lib::optional< int >  _bitrate = {},
lib::optional< int >  _user_limit = {},
lib::optional< std::vector< gateway::objects::permission_overwrite >>  _permission_overwrites = {},
lib::optional< snowflake _parent_id = {},
lib::optional< int >  _rate_limit_per_user = {} 
)

Modify this channel (all parameters optional)

Parameters
_nameString of channel name
_positionInteger of position on channel list
_topicString of channel topic
_nsfwBoolean of whether channel is NSFW or not
_bitrateInteger of the channel bitrate (VOICE CHANNEL ONLY)
_user_limitInteger of the channel max user limit (VOICE CHANNEL ONLY)
_permission_overwritesVector of permission_overwrite objects for overriding permissions
_parent_idSnowflake of category channel belongs in (empty parent puts channel in no category)
Returns
aegis::future<gateway::objects::channel>
aegis::future<gateway::objects::channel> aegis::channel::modify_channel ( modify_channel_t  obj)

Modify this channel (all parameters optional)

See also
aegis::modify_channel_t
Parameters
objStruct of the contents of the request
Returns
aegis::future<gateway::objects::channel>
shared_mutex& aegis::channel::mtx ( ) const
noexcept

Get the mutex for the channel.

Returns
Returns a std::shared_mutex reference for the channel object
bool aegis::channel::nsfw ( ) const
noexcept

Get if this channel is set to NSFW.

Returns
bool whether channel is NSFW or not
permission aegis::channel::perms ( ) const
noexcept

Get bot's permission for this channel.

Returns
Bitmask of current permissions for this channel contained within permission object
aegis::future< rest::rest_reply > aegis::channel::trigger_typing_indicator ( )

Trigger typing indicator in channel (lasts 10 seconds)

Returns
aegis::future<rest::rest_reply>

The documentation for this class was generated from the following files: