aegis.cpp
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
guild.hpp
1 //
2 // guild.hpp
3 // *********
4 //
5 // Copyright (c) 2019 Sharon W (sharon at aegis dot gg)
6 //
7 // Distributed under the MIT License. (See accompanying file LICENSE)
8 //
9 
10 #pragma once
11 
12 #include "aegis/config.hpp"
13 #include "aegis/utility.hpp"
14 #include "aegis/gateway/objects/role.hpp"
15 #include "aegis/snowflake.hpp"
16 #include "aegis/rest/rest_reply.hpp"
17 #include "aegis/ratelimit/ratelimit.hpp"
18 #include "aegis/gateway/objects/permission_overwrite.hpp"
19 #include "aegis/gateway/objects/member.hpp"
20 #include <future>
21 #include <asio.hpp>
22 #include <shared_mutex>
23 #include "aegis/futures.hpp"
24 
25 namespace aegis
26 {
27 
28 #if (AEGIS_HAS_STD_SHARED_MUTEX == 1)
29 using shared_mutex = std::shared_mutex;
30 #else
31 using shared_mutex = std::shared_timed_mutex;
32 #endif
33 
34 using json = nlohmann::json;
35 
36 #pragma region rest params
38 {
39  modify_guild_t & name(const std::string & param) { _name = param; return *this; }
40  modify_guild_t & voice_region(const std::string & param) { _voice_region = param; return *this; }
41  modify_guild_t & verification_level(int param) { _verification_level = param; return *this; }
42  modify_guild_t & default_message_notifications(int param) { _default_message_notifications = param; return *this; }
43  modify_guild_t & explicit_content_filter(int param) { _explicit_content_filter = param; return *this; }
44  modify_guild_t & afk_channel_id(snowflake param) { _afk_channel_id = param; return *this; }
45  modify_guild_t & afk_timeout(int param) { _afk_timeout = param; return *this; }
46  modify_guild_t & icon(const std::string & param) { _icon = param; return *this; }
47  modify_guild_t & owner_id(snowflake param) { _owner_id = param; return *this; }
48  modify_guild_t & splash(const std::string & param) { _splash = param; return *this; }
49 
50  lib::optional<std::string> _name;
51  lib::optional<std::string> _voice_region;
52  lib::optional<int> _verification_level;
53  lib::optional<int> _default_message_notifications;
54  lib::optional<int> _explicit_content_filter;
55  lib::optional<snowflake> _afk_channel_id;
56  lib::optional<int> _afk_timeout;
57  lib::optional<std::string> _icon;
58  lib::optional<snowflake> _owner_id;
59  lib::optional<std::string> _splash;
60 };
61 
63 {
64  create_text_channel_t & name(const std::string & param) { _name = param; return *this; }
65  create_text_channel_t & parent_id(int64_t param) { _parent_id = param; return *this; }
66  create_text_channel_t & nsfw(bool param) { _nsfw = param; return *this; }
67  create_text_channel_t & permission_overwrites(const std::vector<gateway::objects::permission_overwrite> & param)
68  { _permission_overwrites = param; return *this; }
69  std::string _name;
70  int64_t _parent_id = 0;
71  bool _nsfw = false;
72  std::vector<gateway::objects::permission_overwrite> _permission_overwrites;
73 };
74 
76 {
77  create_voice_channel_t & name(const std::string param) { _name = param; return *this; }
78  create_voice_channel_t & bitrate(int32_t param) { _bitrate = param; return *this; }
79  create_voice_channel_t & user_limit(int32_t param) { _user_limit = param; return *this; }
80  create_voice_channel_t & parent_id(int64_t param) { _parent_id = param; return *this; }
81  create_voice_channel_t & permission_overwrites(const std::vector<gateway::objects::permission_overwrite> & param)
82  { _permission_overwrites = param; return *this; }
83  std::string _name;
84  int32_t _bitrate = 0;
85  int32_t _user_limit = 0;
86  int64_t _parent_id = 0;
87  std::vector<gateway::objects::permission_overwrite> _permission_overwrites;
88 };
89 
91 {
92  create_category_channel_t & name(const std::string & param) { _name = param; return *this; }
93  create_category_channel_t & parent_id(int64_t param) { _parent_id = param; return *this; }
94  create_category_channel_t & permission_overwrites(const std::vector<gateway::objects::permission_overwrite> & param)
95  { _permission_overwrites = param; return *this; }
96  std::string _name;
97  int64_t _parent_id = 0;
98  std::vector<gateway::objects::permission_overwrite> _permission_overwrites;
99 };
100 
102 {
103  modify_guild_member_t & user_id(snowflake param) { _user_id = param; return *this; }
104  modify_guild_member_t & nick(const std::string & param) { _nick = param; return *this; }
105  modify_guild_member_t & mute(bool param) { _mute = param; return *this; }
106  modify_guild_member_t & deaf(bool param) { _deaf = param; return *this; }
107  modify_guild_member_t & roles(const std::vector<snowflake> & param) { _roles = param; return *this; }
108  modify_guild_member_t & channel_id(snowflake param) { _channel_id = param; return *this; }
109  snowflake _user_id;
110  lib::optional<std::string> _nick;
111  lib::optional<bool> _mute;
112  lib::optional<bool> _deaf;
113  lib::optional<std::vector<snowflake>> _roles;
114  lib::optional<snowflake> _channel_id;
115 };
116 
118 {
119  create_guild_ban_t & user_id(snowflake param) { _user_id = param; return *this; }
120  create_guild_ban_t & delete_message_days(int8_t param) { _delete_message_days = param; return *this; }
121  create_guild_ban_t & reason(const std::string & param) { _reason = param; return *this; }
122  snowflake _user_id;
123  int8_t _delete_message_days;
124  std::string _reason;
125 };
126 
128 {
129  create_guild_role_t & name(const std::string & param) { _name = param; return *this; }
130  create_guild_role_t & perms(permission param) { _perms = param; return *this; }
131  create_guild_role_t & color(int32_t param) { _color = param; return *this; }
132  create_guild_role_t & hoist(bool param) { _hoist = param; return *this; }
133  create_guild_role_t & mentionable(bool param) { _mentionable = param; return *this; }
134  std::string _name;
135  permission _perms;
136  int32_t _color = 0;
137  bool _hoist = false;
138  bool _mentionable = false;
139 };
140 
142 {
143  modify_guild_role_t & role_id(snowflake param) { _role_id = param; return *this; }
144  modify_guild_role_t & name(const std::string & param) { _name = param; return *this; }
145  modify_guild_role_t & perms(permission param) { _perms = param; return *this; }
146  modify_guild_role_t & color(int32_t param) { _color = param; return *this; }
147  modify_guild_role_t & hoist(bool param) { _hoist = param; return *this; }
148  modify_guild_role_t & mentionable(bool param) { _mentionable = param; return *this; }
149  snowflake _role_id;
150  std::string _name;
151  permission _perms;
152  int32_t _color = 0;
153  bool _hoist = false;
154  bool _mentionable = false;
155 };
156 #pragma endregion
157 
159 class guild
160 {
161 public:
163 
169  AEGIS_DECL explicit guild(const int32_t _shard_id, const snowflake _id, core * _bot, asio::io_context & _io);
170 
171  AEGIS_DECL ~guild();
172 
173  guild(const guild &) = delete;
174  guild(guild &&) = delete;
175  guild & operator=(const guild &) = delete;
176 
177  int32_t shard_id; /*< shard that receives this guild's messages */
178  snowflake guild_id; /*< snowflake of this guild */
179 
180 #if !defined(AEGIS_DISABLE_ALL_CACHE)
181 
186  {
187  return permission(base_permissions(self()));
188  }
189 
191 
194  AEGIS_DECL user * self() const;
195 
197 
200  std::string get_name() const noexcept
201  {
202  std::shared_lock<shared_mutex> l(_m);
203  std::string _name = name;
204  return std::move(_name);
205  }
206 
208 
211  std::string get_icon() const noexcept
212  {
213  std::shared_lock<shared_mutex> l(_m);
214  std::string _icon = icon;
215  return std::move(_icon);
216  }
217 
219 
222  std::string get_splash() const noexcept
223  {
224  std::shared_lock<shared_mutex> l(_m);
225  std::string _splash = splash;
226  return std::move(_splash);
227  }
228 
230 
233  std::string get_region() const noexcept
234  {
235  std::shared_lock<shared_mutex> l(_m);
236  std::string _region = region;
237  return std::move(_region);
238  }
239 
241 
246  AEGIS_DECL bool member_has_role(snowflake member_id, snowflake role_id) const noexcept;
247 
249 
252  AEGIS_DECL int32_t get_member_count() const noexcept;
253 
255 
260  AEGIS_DECL permission get_permissions(snowflake member_id, snowflake channel_id) const;
261 
263 
268  AEGIS_DECL permission get_permissions(const user * _member, const channel * _channel) const;
269 
271 
274  int64_t base_permissions() const
275  {
276  std::shared_lock<shared_mutex> l(_m);
277  return base_permissions(self());
278  }
279 
281 
284  int64_t base_permissions(const user * _member) const noexcept
285  {
286  std::shared_lock<shared_mutex> l(_m);
287  return base_permissions(*_member);
288  }
289 
291 
294  AEGIS_DECL int64_t base_permissions(const user & _member) const noexcept;
295 
297 
303  AEGIS_DECL int64_t compute_overwrites(const int64_t _base_permissions, const user & _member, const channel & _channel) const noexcept;
304 
306 
310  AEGIS_DECL const gateway::objects::role get_role(const int64_t r) const;
311 
313 
316  AEGIS_DECL const snowflake get_owner() const noexcept;
317 #endif
318 
320 
323  snowflake get_id() const noexcept
324  {
325  return guild_id;
326  }
327 
329 
333  AEGIS_DECL channel * get_channel(snowflake id) const noexcept;
334 
336 
340 
342 
358  lib::optional<std::string> name = {},
359  lib::optional<std::string> voice_region = {}, lib::optional<int> verification_level = {},
360  lib::optional<int> default_message_notifications = {}, lib::optional<int> explicit_content_filter = {},
361  lib::optional<snowflake> afk_channel_id = {}, lib::optional<int> afk_timeout = {},
362  lib::optional<std::string> icon = {}, lib::optional<snowflake> owner_id = {},
363  lib::optional<std::string> splash = {}
364  );
365 
367 
373  {
374  return modify_guild(obj._name, obj._voice_region, obj._verification_level, obj._default_message_notifications,
375  obj._explicit_content_filter, obj._afk_channel_id, obj._afk_timeout, obj._icon,
376  obj._owner_id, obj._splash);
377  }
378 
380 
384 
386 
393  AEGIS_DECL aegis::future<gateway::objects::channel> create_text_channel(const std::string & name, int64_t parent_id = 0, bool nsfw = false,
394  const std::vector<gateway::objects::permission_overwrite> & permission_overwrites = {});
395 
397 
403  {
404  return create_text_channel(obj._name, obj._parent_id, obj._nsfw, obj._permission_overwrites);
405  }
406 
408 
417  AEGIS_DECL aegis::future<gateway::objects::channel> create_voice_channel(const std::string & name, int32_t bitrate = 0, int32_t user_limit = 0, int64_t parent_id = 0,
418  const std::vector<gateway::objects::permission_overwrite> & permission_overwrites = {});
419 
421 
427  {
428  return create_voice_channel(obj._name, obj._bitrate, obj._user_limit, obj._parent_id, obj._permission_overwrites);
429  }
430 
432 
438  AEGIS_DECL aegis::future<gateway::objects::channel> create_category_channel(const std::string & name, int64_t parent_id,
439  const std::vector<gateway::objects::permission_overwrite> & permission_overwrites);
440 
442 
448  {
449  return create_category_channel(obj._name, obj._parent_id, obj._permission_overwrites);
450  }
451 
453 
457 
460 
469  AEGIS_DECL aegis::future<gateway::objects::member> modify_guild_member(snowflake user_id, lib::optional<std::string> nick, lib::optional<bool> mute,
470  lib::optional<bool> deaf, lib::optional<std::vector<snowflake>> roles,
471  lib::optional<snowflake> channel_id);
472 
475 
481  {
482  return modify_guild_member(obj._user_id, obj._nick, obj._mute, obj._deaf, obj._roles, obj._channel_id);
483  }
484 
486 
490  AEGIS_DECL aegis::future<rest::rest_reply> modify_my_nick(const std::string & newname);
491 
493 
499 
501 
507 
509 
514 
516 
521  AEGIS_DECL aegis::future<rest::rest_reply> create_guild_ban(snowflake user_id, int8_t delete_message_days = 0, const std::string & reason = "");
522 
524 
530  {
531  return create_guild_ban(obj._user_id, obj._delete_message_days, obj._reason);
532  }
533 
535 
540 
542 
551  AEGIS_DECL aegis::future<gateway::objects::role> create_guild_role(const std::string & name, permission _perms, int32_t color, bool hoist, bool mentionable);
552 
554 
561  {
562  return create_guild_role(obj._name, obj._perms, obj._color, obj._hoist, obj._mentionable);
563  }
564 
566 
571  AEGIS_DECL aegis::future<rest::rest_reply> modify_guild_role_positions(snowflake role_id, int16_t position);
572 
574 
584  AEGIS_DECL aegis::future<gateway::objects::role> modify_guild_role(snowflake role_id, const std::string & name, permission _perms, int32_t color,
585  bool hoist, bool mentionable);
586 
588 
595  {
596  return modify_guild_role(obj._role_id, obj._name, obj._perms, obj._color, obj._hoist, obj._mentionable);
597  }
598 
600 
605 
607 
612 
614 
618  AEGIS_DECL aegis::future<rest::rest_reply> begin_guild_prune(int16_t days);
619 
621 
625 
627 
631 
633 
637 
639 
643 
645 
649 
651 
655 
657 
661 
663 
667 
669 
673 
675 
680  AEGIS_DECL core & get_bot() const noexcept;
681 
683 
687  AEGIS_DECL user * find_member(snowflake member_id) const noexcept;
688 
690 
694  AEGIS_DECL channel * find_channel(snowflake channel_id) const noexcept;
695 
697 
701  AEGIS_DECL channel * find_channel(std::string channel_name) const noexcept;
702 
704 
708  AEGIS_DECL lib::optional<gateway::objects::role> find_role(snowflake role_id) const noexcept;
709 
711 
715  AEGIS_DECL lib::optional<gateway::objects::role> find_role(std::string role_name) const noexcept;
716 
718 
721  std::unordered_map<snowflake, channel*> get_channels() const noexcept
722  {
723  std::shared_lock<shared_mutex> l(_m);
724  std::unordered_map<snowflake, channel*> _list = channels;
725  return std::move(_list);
726  }
727 
728 #if !defined(AEGIS_DISABLE_ALL_CACHE)
729 
733  std::unordered_map<snowflake, user*> get_members() const noexcept
734  {
735  std::shared_lock<shared_mutex> l(_m);
736  std::unordered_map<snowflake, user*> _list = members;
737  return std::move(_list);
738  }
739 
741 
744  std::unordered_map<snowflake, gateway::objects::role> get_roles() const noexcept
745  {
746  std::shared_lock<shared_mutex> l(_m);
747  std::unordered_map<snowflake, gateway::objects::role> _list = roles;
748  return std::move(_list);
749  }
750 
752 
755  std::unordered_map<snowflake, gateway::objects::voice_state> get_voicestates() const noexcept
756  {
757  std::shared_lock<shared_mutex> l(_m);
758  std::unordered_map<snowflake, gateway::objects::voice_state> _list = voice_states;
759  return std::move(_list);
760  }
761 
763 
766  const std::unordered_map<snowflake, user*> & get_members_nocopy() const noexcept
767  {
768  return members;
769  }
770 
772 
775  const std::unordered_map<snowflake, gateway::objects::role> & get_roles_nocopy() const noexcept
776  {
777  return roles;
778  }
779 #endif
780 
782 
785  const std::unordered_map<snowflake, channel*> & get_channels_nocopy() const noexcept
786  {
787  return channels;
788  }
789 
790  shared_mutex & mtx()
791  {
792  return _m;
793  }
794 
795 private:
796  friend class core;
797  friend class user;
798 
799  std::unordered_map<snowflake, channel*> channels;
800 #if !defined(AEGIS_DISABLE_ALL_CACHE)
801  std::unordered_map<snowflake, user*> members;
802  std::unordered_map<snowflake, gateway::objects::role> roles;
803  std::unordered_map<snowflake, gateway::objects::emoji> emojis;
804  std::unordered_map<snowflake, gateway::objects::voice_state> voice_states;
805 #endif
806 
807 #if !defined(AEGIS_DISABLE_ALL_CACHE)
808  AEGIS_DECL void _add_member(user * _member) noexcept;
809 
810  AEGIS_DECL void _add_member_nolock(user * _member) noexcept;
811 
812  AEGIS_DECL void _remove_member(snowflake member_id) noexcept;
813 
814  AEGIS_DECL void _load_presence(const json & obj) noexcept;
815 
816  AEGIS_DECL void _load_emoji(const json & obj) noexcept;
817 
818  AEGIS_DECL void _load_role(const json & obj) noexcept;
819 
820  AEGIS_DECL void _remove_role(snowflake role_id) noexcept;
821 
822  AEGIS_DECL void _load_voicestate(const json & obj) noexcept;
823 #endif
824 
825  AEGIS_DECL void _load(const json & obj, shards::shard * _shard) noexcept;
826 
828  AEGIS_DECL user * _find_member(snowflake member_id) const noexcept;
829 
831  AEGIS_DECL channel * _find_channel(snowflake channel_id) const noexcept;
832 
833  AEGIS_DECL void _remove_channel(snowflake channel_id) noexcept;
834 
835 #if !defined(AEGIS_DISABLE_ALL_CACHE)
836  std::string name;
837  std::string icon;
838  std::string splash;
839  snowflake owner_id = 0;
840  std::string region;
841  snowflake afk_channel_id = 0;
842  uint32_t afk_timeout = 0;//in seconds
843  bool embed_enabled = false;
844  snowflake embed_channel_id = 0;
845  uint32_t verification_level = 0;
846  uint32_t default_message_notifications = 0;
847  uint32_t mfa_level = 0;
848  std::string joined_at;
849  bool large = false;
850  bool unavailable = false;
851  uint32_t member_count = 0;
852  //std::string m_voice_states;//this is really an array
853  bool is_init = true;
854 #endif
855  core * _bot;
856  asio::io_context & _io_context;
857  mutable shared_mutex _m;
858 };
859 
860 }
aegis::future< rest::rest_reply > modify_my_nick(const std::string &newname)
Modify own nickname.
Definition: guild.cpp:823
aegis::future< gateway::objects::role > create_guild_role(const std::string &name, permission _perms, int32_t color, bool hoist, bool mentionable)
Create a guild role.
Definition: guild.cpp:898
std::unordered_map< snowflake, user * > get_members() const noexcept
Obtain map of members.
Definition: guild.hpp:733
Stores creation time and extra data specific to Discord for entities.
Definition: snowflake.hpp:21
aegis::future< gateway::objects::role > modify_guild_role(snowflake role_id, const std::string &name, permission _perms, int32_t color, bool hoist, bool mentionable)
Modify a guild role.
Definition: guild.cpp:924
aegis::future< rest::rest_reply > modify_guild_integration()
Modify a guild integration.
Definition: guild.cpp:1011
Utility class for permission checks.
Definition: permission.hpp:57
aegis::future< gateway::objects::member > modify_guild_member(snowflake user_id, lib::optional< std::string > nick, lib::optional< bool > mute, lib::optional< bool > deaf, lib::optional< std::vector< snowflake >> roles, lib::optional< snowflake > channel_id)
Definition: guild.cpp:768
aegis::future< rest::rest_reply > modify_guild_embed()
Modify the guild embed settings.
Definition: guild.cpp:1059
aegis::future< rest::rest_reply > create_guild_ban(snowflake user_id, int8_t delete_message_days=0, const std::string &reason="")
Create a new guild ban.
Definition: guild.cpp:872
std::string get_name() const noexcept
Get name of guild.
Definition: guild.hpp:200
aegis::future< rest::rest_reply > modify_guild_role_positions(snowflake role_id, int16_t position)
Modify the guild role positions.
Definition: guild.cpp:911
guild(const int32_t _shard_id, const snowflake _id, core *_bot, asio::io_context &_io)
Create a new guild.
Definition: guild.cpp:25
aegis::future< gateway::objects::channel > create_voice_channel(const std::string &name, int32_t bitrate=0, int32_t user_limit=0, int64_t parent_id=0, const std::vector< gateway::objects::permission_overwrite > &permission_overwrites={})
Create a voice channel.
Definition: guild.cpp:675
lib::optional< gateway::objects::role > find_role(snowflake role_id) const noexcept
Obtain a role by snowflake.
Definition: guild.cpp:192
aegis::future< rest::rest_reply > create_guild_ban(create_guild_ban_t obj)
Create a new guild ban.
Definition: guild.hpp:529
aegis::future< rest::rest_reply > get_guild_embed()
Get the guild embed settings.
Definition: guild.cpp:1047
std::unordered_map< snowflake, channel * > get_channels() const noexcept
Obtain map of channels.
Definition: guild.hpp:721
aegis::future< gateway::objects::guild > modify_guild(lib::optional< std::string > name={}, lib::optional< std::string > voice_region={}, lib::optional< int > verification_level={}, lib::optional< int > default_message_notifications={}, lib::optional< int > explicit_content_filter={}, lib::optional< snowflake > afk_channel_id={}, lib::optional< int > afk_timeout={}, lib::optional< std::string > icon={}, lib::optional< snowflake > owner_id={}, lib::optional< std::string > splash={})
Modify guild information.
Definition: guild.cpp:581
Definition: guild.hpp:90
Class for performing actions pertaining to a specified guild.
Definition: guild.hpp:159
aegis::future< rest::rest_reply > get_guild_integrations()
Get guild integrations.
Definition: guild.cpp:987
aegis::future< gateway::objects::role > add_guild_member_role(snowflake user_id, snowflake role_id)
Add a role to guild member.
Definition: guild.cpp:836
const snowflake get_owner() const noexcept
Get owner of guild.
Definition: guild.cpp:144
Definition: guild.hpp:37
channel * get_channel(snowflake id) const noexcept
Get channel internally.
Definition: guild.cpp:564
aegis::future< rest::rest_reply > delete_guild_integration()
Delete a guild integration.
Definition: guild.cpp:1023
Primary class for managing a bot interface.
Definition: core.hpp:157
permission perms()
Get bot's current permissions for this guild.
Definition: guild.hpp:185
aegis::future< rest::rest_reply > get_guild_invites()
Get active guild invites.
Definition: guild.cpp:975
const gateway::objects::role get_role(const int64_t r) const
Get role.
Definition: guild.cpp:329
permission get_permissions(snowflake member_id, snowflake channel_id) const
Get guild permissions for member in channel.
Definition: guild.cpp:210
aegis::future< gateway::objects::channel > create_text_channel(create_text_channel_t obj)
Create a text channel.
Definition: guild.hpp:402
Class for performing actions pertaining to a specified channel.
Definition: channel.hpp:170
Definition: guild.hpp:62
aegis::future< gateway::objects::guild > modify_guild(modify_guild_t obj)
Modify guild information.
Definition: guild.hpp:372
bool member_has_role(snowflake member_id, snowflake role_id) const noexcept
Check if member has role.
Definition: guild.cpp:79
Stores user-specific and guild-specific attributes of users.
Definition: user.hpp:37
aegis::future< rest::rest_reply > delete_guild()
Delete a guild.
Definition: guild.cpp:617
int64_t base_permissions(const user *_member) const noexcept
Get base guild permissions for self.
Definition: guild.hpp:284
aegis::future< gateway::objects::channel > create_category_channel(const std::string &name, int64_t parent_id, const std::vector< gateway::objects::permission_overwrite > &permission_overwrites)
Create a category.
Definition: guild.cpp:720
aegis::future< rest::rest_reply > get_guild_prune_count(int16_t days)
Get a count of members that would be pruned.
Definition: guild.cpp:951
aegis::future< rest::rest_reply > remove_guild_member(snowflake user_id)
Remove guild member (kick)
Definition: guild.cpp:860
int64_t base_permissions() const
Get base guild permissions for member.
Definition: guild.hpp:274
aegis::future< rest::rest_reply > remove_guild_member_role(snowflake user_id, snowflake role_id)
Remove a role from guild member.
Definition: guild.cpp:848
aegis::future< gateway::objects::channel > create_voice_channel(create_voice_channel_t obj)
Create a voice channel.
Definition: guild.hpp:426
snowflake get_id() const noexcept
Get the snowflake of this guild.
Definition: guild.hpp:323
const std::unordered_map< snowflake, user * > & get_members_nocopy() const noexcept
Obtain map of members - caller must lock guild._m to ensure no race conditions.
Definition: guild.hpp:766
aegis::future< rest::rest_reply > sync_guild_integration()
Get the guild integrations.
Definition: guild.cpp:1035
aegis::future< gateway::objects::role > create_guild_role(create_guild_role_t obj)
Create a guild role.
Definition: guild.hpp:560
std::string get_region() const noexcept
Get region of guild.
Definition: guild.hpp:233
const std::unordered_map< snowflake, channel * > & get_channels_nocopy() const noexcept
Obtain map of channels - caller must lock guild._m to ensure no race conditions.
Definition: guild.hpp:785
core & get_bot() const noexcept
Gets the Bot object.
Definition: guild.cpp:44
aegis::future< gateway::objects::channel > create_text_channel(const std::string &name, int64_t parent_id=0, bool nsfw=false, const std::vector< gateway::objects::permission_overwrite > &permission_overwrites={})
Create a text channel.
Definition: guild.cpp:630
future
Definition: futures.hpp:41
channel * find_channel(snowflake channel_id) const noexcept
Obtain a pointer to a channel by snowflake.
Definition: guild.cpp:174
aegis::future< rest::rest_reply > remove_guild_ban(snowflake user_id)
Remove a guild ban.
Definition: guild.cpp:886
Definition: guild.hpp:127
std::unordered_map< snowflake, gateway::objects::role > get_roles() const noexcept
Obtain map of roles.
Definition: guild.hpp:744
Definition: guild.hpp:75
Definition: guild.hpp:117
Definition: guild.hpp:141
int32_t get_member_count() const noexcept
Get count of members in guild (potentially inaccurate)
Definition: guild.cpp:365
aegis::future< rest::rest_reply > leave()
Leave the guild this object is associated with.
Definition: guild.cpp:1069
const std::unordered_map< snowflake, gateway::objects::role > & get_roles_nocopy() const noexcept
Obtain map of roles - caller must lock guild._m to ensure no race conditions.
Definition: guild.hpp:775
user * find_member(snowflake member_id) const noexcept
Obtain a pointer to a member by snowflake.
Definition: guild.cpp:149
aegis::future< rest::rest_reply > create_guild_integration()
Create a new guild integration.
Definition: guild.cpp:999
std::string get_icon() const noexcept
Get icon of guild.
Definition: guild.hpp:211
aegis::future< gateway::objects::member > modify_guild_member(modify_guild_member_t obj)
Definition: guild.hpp:480
Stores info pertaining to guild roles.
Definition: role.hpp:34
Definition: guild.hpp:101
aegis::future< rest::rest_reply > begin_guild_prune(int16_t days)
Perform a guild prune.
Definition: guild.cpp:963
aegis::future< gateway::objects::role > modify_guild_role(modify_guild_role_t obj)
Modify a guild role.
Definition: guild.hpp:594
std::string get_splash() const noexcept
Get splash of guild.
Definition: guild.hpp:222
aegis::future< rest::rest_reply > delete_guild_role(snowflake role_id)
Delete a guild role.
Definition: guild.cpp:937
aegis::future< rest::rest_reply > modify_channel_positions()
Modify positions of channels.
Definition: guild.cpp:758
aegis::future< gateway::objects::channel > create_category_channel(create_category_channel_t obj)
Create a category.
Definition: guild.hpp:447
aegis::future< gateway::objects::guild > get_guild()
Get guild information.
Definition: guild.cpp:575
int64_t compute_overwrites(const int64_t _base_permissions, const user &_member, const channel &_channel) const noexcept
Calculate permission overrides for member in channel.
Definition: guild.cpp:267
std::unordered_map< snowflake, gateway::objects::voice_state > get_voicestates() const noexcept
Obtain map of voice states.
Definition: guild.hpp:755