You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

RestGuild.cs 28 kB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
9 years ago
7 years ago
7 years ago
7 years ago
7 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
7 years ago
7 years ago
7 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
Add support for channel categories (#907) commit a85c5814a74e473e95fe172f0379cbc7f9f951d8 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:25:48 2018 -0500 Code cleanup commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1 Author: Christopher F <computerizedtaco@gmail.com> Date: Sat Jan 6 22:08:28 2018 -0500 Add support for channel categories (#907) commit 41ed9106f2b05530acbf06b245c9aa618011d815 Author: mrspits4ever <spits.lucas@gmail.com> Date: Thu Dec 14 20:02:57 2017 +0100 removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel commit 71142c310847886dff80c49e9357dd0786d67a1b Merge: 4589d731 678a7238 Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:53 2017 +0100 Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories commit 4589d73187871c98485ed25c6d223706927af7ec Author: mrspits4ever <spits.lucas@gmail.com> Date: Wed Dec 13 21:17:46 2017 +0100 adressed requested changes commit d59b038efa048b2279602e2015ddd2c185e58d63 Author: pegasy <pegasy@users.noreply.github.com> Date: Mon Sep 25 18:53:23 2017 +0200 Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named. commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 19:08:25 2017 +0200 removed Guild from class name for ChannelCategory Renamed all properties to use Category instead of Parent Throw exception on GetUsers / GetInvites etc for categories commit e18bd8c799d2327270021c05866cb2e97ad4671b Author: pegasy <pegasy@users.noreply.github.com> Date: Sun Sep 24 15:49:51 2017 +0200 Add support for channel categories (as its own channel type)
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. using Discord.Audio;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.Immutable;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using EmbedModel = Discord.API.GuildEmbed;
  9. using Model = Discord.API.Guild;
  10. namespace Discord.Rest
  11. {
  12. /// <summary>
  13. /// Represents a REST-based guild/server.
  14. /// </summary>
  15. [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
  16. public class RestGuild : RestEntity<ulong>, IGuild, IUpdateable
  17. {
  18. private ImmutableDictionary<ulong, RestRole> _roles;
  19. private ImmutableArray<GuildEmote> _emotes;
  20. private ImmutableArray<string> _features;
  21. /// <inheritdoc />
  22. public string Name { get; private set; }
  23. /// <inheritdoc />
  24. public int AFKTimeout { get; private set; }
  25. /// <inheritdoc />
  26. public bool IsEmbeddable { get; private set; }
  27. /// <inheritdoc />
  28. public VerificationLevel VerificationLevel { get; private set; }
  29. /// <inheritdoc />
  30. public MfaLevel MfaLevel { get; private set; }
  31. /// <inheritdoc />
  32. public DefaultMessageNotifications DefaultMessageNotifications { get; private set; }
  33. /// <inheritdoc />
  34. public ulong? AFKChannelId { get; private set; }
  35. /// <inheritdoc />
  36. public ulong? EmbedChannelId { get; private set; }
  37. /// <inheritdoc />
  38. public ulong? SystemChannelId { get; private set; }
  39. /// <inheritdoc />
  40. public ulong OwnerId { get; private set; }
  41. /// <inheritdoc />
  42. public string VoiceRegionId { get; private set; }
  43. /// <inheritdoc />
  44. public string IconId { get; private set; }
  45. /// <inheritdoc />
  46. public string SplashId { get; private set; }
  47. internal bool Available { get; private set; }
  48. /// <inheritdoc />
  49. public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
  50. [Obsolete("DefaultChannelId is deprecated, use GetDefaultChannelAsync")]
  51. public ulong DefaultChannelId => Id;
  52. /// <inheritdoc />
  53. public string IconUrl => CDN.GetGuildIconUrl(Id, IconId);
  54. /// <inheritdoc />
  55. public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId);
  56. public RestRole EveryoneRole => GetRole(Id);
  57. public IReadOnlyCollection<RestRole> Roles => _roles.ToReadOnlyCollection();
  58. /// <inheritdoc />
  59. public IReadOnlyCollection<GuildEmote> Emotes => _emotes;
  60. /// <inheritdoc />
  61. public IReadOnlyCollection<string> Features => _features;
  62. internal RestGuild(BaseDiscordClient client, ulong id)
  63. : base(client, id)
  64. {
  65. }
  66. internal static RestGuild Create(BaseDiscordClient discord, Model model)
  67. {
  68. var entity = new RestGuild(discord, model.Id);
  69. entity.Update(model);
  70. return entity;
  71. }
  72. internal void Update(Model model)
  73. {
  74. AFKChannelId = model.AFKChannelId;
  75. EmbedChannelId = model.EmbedChannelId;
  76. SystemChannelId = model.SystemChannelId;
  77. AFKTimeout = model.AFKTimeout;
  78. IsEmbeddable = model.EmbedEnabled;
  79. IconId = model.Icon;
  80. Name = model.Name;
  81. OwnerId = model.OwnerId;
  82. VoiceRegionId = model.Region;
  83. SplashId = model.Splash;
  84. VerificationLevel = model.VerificationLevel;
  85. MfaLevel = model.MfaLevel;
  86. DefaultMessageNotifications = model.DefaultMessageNotifications;
  87. if (model.Emojis != null)
  88. {
  89. var emotes = ImmutableArray.CreateBuilder<GuildEmote>(model.Emojis.Length);
  90. for (int i = 0; i < model.Emojis.Length; i++)
  91. emotes.Add(model.Emojis[i].ToEntity());
  92. _emotes = emotes.ToImmutableArray();
  93. }
  94. else
  95. _emotes = ImmutableArray.Create<GuildEmote>();
  96. if (model.Features != null)
  97. _features = model.Features.ToImmutableArray();
  98. else
  99. _features = ImmutableArray.Create<string>();
  100. var roles = ImmutableDictionary.CreateBuilder<ulong, RestRole>();
  101. if (model.Roles != null)
  102. {
  103. for (int i = 0; i < model.Roles.Length; i++)
  104. roles[model.Roles[i].Id] = RestRole.Create(Discord, this, model.Roles[i]);
  105. }
  106. _roles = roles.ToImmutable();
  107. Available = true;
  108. }
  109. internal void Update(EmbedModel model)
  110. {
  111. EmbedChannelId = model.ChannelId;
  112. IsEmbeddable = model.Enabled;
  113. }
  114. //General
  115. /// <inheritdoc />
  116. public async Task UpdateAsync(RequestOptions options = null)
  117. => Update(await Discord.ApiClient.GetGuildAsync(Id, options).ConfigureAwait(false));
  118. /// <inheritdoc />
  119. public Task DeleteAsync(RequestOptions options = null)
  120. => GuildHelper.DeleteAsync(this, Discord, options);
  121. /// <inheritdoc />
  122. /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception>
  123. public async Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null)
  124. {
  125. var model = await GuildHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
  126. Update(model);
  127. }
  128. /// <inheritdoc />
  129. /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception>
  130. public async Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null)
  131. {
  132. var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false);
  133. Update(model);
  134. }
  135. /// <inheritdoc />
  136. /// <exception cref="ArgumentNullException"><paramref name="args" /> is <c>null</c>.</exception>
  137. public async Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null)
  138. {
  139. var arr = args.ToArray();
  140. await GuildHelper.ReorderChannelsAsync(this, Discord, arr, options).ConfigureAwait(false);
  141. }
  142. /// <inheritdoc />
  143. public async Task ReorderRolesAsync(IEnumerable<ReorderRoleProperties> args, RequestOptions options = null)
  144. {
  145. var models = await GuildHelper.ReorderRolesAsync(this, Discord, args, options).ConfigureAwait(false);
  146. foreach (var model in models)
  147. {
  148. var role = GetRole(model.Id);
  149. role?.Update(model);
  150. }
  151. }
  152. /// <inheritdoc />
  153. public Task LeaveAsync(RequestOptions options = null)
  154. => GuildHelper.LeaveAsync(this, Discord, options);
  155. //Bans
  156. public Task<IReadOnlyCollection<RestBan>> GetBansAsync(RequestOptions options = null)
  157. => GuildHelper.GetBansAsync(this, Discord, options);
  158. public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null)
  159. => GuildHelper.GetBanAsync(this, Discord, user.Id, options);
  160. public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null)
  161. => GuildHelper.GetBanAsync(this, Discord, userId, options);
  162. /// <inheritdoc />
  163. public Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null)
  164. => GuildHelper.AddBanAsync(this, Discord, user.Id, pruneDays, reason, options);
  165. /// <inheritdoc />
  166. public Task AddBanAsync(ulong userId, int pruneDays = 0, string reason = null, RequestOptions options = null)
  167. => GuildHelper.AddBanAsync(this, Discord, userId, pruneDays, reason, options);
  168. /// <inheritdoc />
  169. public Task RemoveBanAsync(IUser user, RequestOptions options = null)
  170. => GuildHelper.RemoveBanAsync(this, Discord, user.Id, options);
  171. /// <inheritdoc />
  172. public Task RemoveBanAsync(ulong userId, RequestOptions options = null)
  173. => GuildHelper.RemoveBanAsync(this, Discord, userId, options);
  174. //Channels
  175. public Task<IReadOnlyCollection<RestGuildChannel>> GetChannelsAsync(RequestOptions options = null)
  176. => GuildHelper.GetChannelsAsync(this, Discord, options);
  177. public Task<RestGuildChannel> GetChannelAsync(ulong id, RequestOptions options = null)
  178. => GuildHelper.GetChannelAsync(this, Discord, id, options);
  179. public async Task<RestTextChannel> GetTextChannelAsync(ulong id, RequestOptions options = null)
  180. {
  181. var channel = await GuildHelper.GetChannelAsync(this, Discord, id, options).ConfigureAwait(false);
  182. return channel as RestTextChannel;
  183. }
  184. public async Task<IReadOnlyCollection<RestTextChannel>> GetTextChannelsAsync(RequestOptions options = null)
  185. {
  186. var channels = await GuildHelper.GetChannelsAsync(this, Discord, options).ConfigureAwait(false);
  187. return channels.Select(x => x as RestTextChannel).Where(x => x != null).ToImmutableArray();
  188. }
  189. public async Task<RestVoiceChannel> GetVoiceChannelAsync(ulong id, RequestOptions options = null)
  190. {
  191. var channel = await GuildHelper.GetChannelAsync(this, Discord, id, options).ConfigureAwait(false);
  192. return channel as RestVoiceChannel;
  193. }
  194. public async Task<IReadOnlyCollection<RestVoiceChannel>> GetVoiceChannelsAsync(RequestOptions options = null)
  195. {
  196. var channels = await GuildHelper.GetChannelsAsync(this, Discord, options).ConfigureAwait(false);
  197. return channels.Select(x => x as RestVoiceChannel).Where(x => x != null).ToImmutableArray();
  198. }
  199. public async Task<IReadOnlyCollection<RestCategoryChannel>> GetCategoryChannelsAsync(RequestOptions options = null)
  200. {
  201. var channels = await GuildHelper.GetChannelsAsync(this, Discord, options).ConfigureAwait(false);
  202. return channels.Select(x => x as RestCategoryChannel).Where(x => x != null).ToImmutableArray();
  203. }
  204. public async Task<RestVoiceChannel> GetAFKChannelAsync(RequestOptions options = null)
  205. {
  206. var afkId = AFKChannelId;
  207. if (afkId.HasValue)
  208. {
  209. var channel = await GuildHelper.GetChannelAsync(this, Discord, afkId.Value, options).ConfigureAwait(false);
  210. return channel as RestVoiceChannel;
  211. }
  212. return null;
  213. }
  214. public async Task<RestTextChannel> GetDefaultChannelAsync(RequestOptions options = null)
  215. {
  216. var channels = await GetTextChannelsAsync(options).ConfigureAwait(false);
  217. var user = await GetCurrentUserAsync(options).ConfigureAwait(false);
  218. return channels
  219. .Where(c => user.GetPermissions(c).ViewChannel)
  220. .OrderBy(c => c.Position)
  221. .FirstOrDefault();
  222. }
  223. public async Task<RestGuildChannel> GetEmbedChannelAsync(RequestOptions options = null)
  224. {
  225. var embedId = EmbedChannelId;
  226. if (embedId.HasValue)
  227. return await GuildHelper.GetChannelAsync(this, Discord, embedId.Value, options).ConfigureAwait(false);
  228. return null;
  229. }
  230. public async Task<RestTextChannel> GetSystemChannelAsync(RequestOptions options = null)
  231. {
  232. var systemId = SystemChannelId;
  233. if (systemId.HasValue)
  234. {
  235. var channel = await GuildHelper.GetChannelAsync(this, Discord, systemId.Value, options).ConfigureAwait(false);
  236. return channel as RestTextChannel;
  237. }
  238. return null;
  239. }
  240. /// <summary>
  241. /// Creates a text channel with the provided name.
  242. /// </summary>
  243. /// <param name="name">The name of the new channel.</param>
  244. /// <param name="options">The options to be used when sending the request.</param>
  245. /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param>
  246. /// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception>
  247. /// <returns>
  248. /// The created text channel.
  249. /// </returns>
  250. public Task<RestTextChannel> CreateTextChannelAsync(string name, Action<TextChannelProperties> func = null, RequestOptions options = null)
  251. => GuildHelper.CreateTextChannelAsync(this, Discord, name, options, func);
  252. /// <summary>
  253. /// Creates a voice channel with the provided name.
  254. /// </summary>
  255. /// <param name="name">The name of the new channel.</param>
  256. /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param>
  257. /// <param name="options">The options to be used when sending the request.</param>
  258. /// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception>
  259. /// <returns>
  260. /// The created voice channel.
  261. /// </returns>
  262. public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null)
  263. => GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options, func);
  264. /// <summary>
  265. /// Creates a category channel with the provided name.
  266. /// </summary>
  267. /// <param name="name">The name of the new channel.</param>
  268. /// <param name="options">The options to be used when sending the request.</param>
  269. /// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception>
  270. /// <returns>
  271. /// The created category channel.
  272. /// </returns>
  273. public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, RequestOptions options = null)
  274. => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options);
  275. //Integrations
  276. public Task<IReadOnlyCollection<RestGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null)
  277. => GuildHelper.GetIntegrationsAsync(this, Discord, options);
  278. public Task<RestGuildIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null)
  279. => GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options);
  280. //Invites
  281. public Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null)
  282. => GuildHelper.GetInvitesAsync(this, Discord, options);
  283. /// <summary>
  284. /// Gets the vanity invite URL of this guild.
  285. /// </summary>
  286. /// <param name="options">The options to be used when sending the request.</param>
  287. /// <returns>
  288. /// A partial metadata of the vanity invite found within this guild.
  289. /// </returns>
  290. public Task<RestInviteMetadata> GetVanityInviteAsync(RequestOptions options = null)
  291. => GuildHelper.GetVanityInviteAsync(this, Discord, options);
  292. //Roles
  293. public RestRole GetRole(ulong id)
  294. {
  295. if (_roles.TryGetValue(id, out RestRole value))
  296. return value;
  297. return null;
  298. }
  299. public async Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?),
  300. bool isHoisted = false, RequestOptions options = null)
  301. {
  302. var role = await GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, options).ConfigureAwait(false);
  303. _roles = _roles.Add(role.Id, role);
  304. return role;
  305. }
  306. //Users
  307. public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(RequestOptions options = null)
  308. => GuildHelper.GetUsersAsync(this, Discord, null, null, options);
  309. public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null)
  310. => GuildHelper.GetUserAsync(this, Discord, id, options);
  311. public Task<RestGuildUser> GetCurrentUserAsync(RequestOptions options = null)
  312. => GuildHelper.GetUserAsync(this, Discord, Discord.CurrentUser.Id, options);
  313. public Task<RestGuildUser> GetOwnerAsync(RequestOptions options = null)
  314. => GuildHelper.GetUserAsync(this, Discord, OwnerId, options);
  315. /// <inheritdoc />
  316. public Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null)
  317. => GuildHelper.PruneUsersAsync(this, Discord, days, simulate, options);
  318. //Audit logs
  319. public IAsyncEnumerable<IReadOnlyCollection<RestAuditLogEntry>> GetAuditLogsAsync(int limit, RequestOptions options = null)
  320. => GuildHelper.GetAuditLogsAsync(this, Discord, null, limit, options);
  321. //Webhooks
  322. public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
  323. => GuildHelper.GetWebhookAsync(this, Discord, id, options);
  324. public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null)
  325. => GuildHelper.GetWebhooksAsync(this, Discord, options);
  326. /// <summary>
  327. /// Returns the name of the guild.
  328. /// </summary>
  329. /// <returns>
  330. /// The name of the guild.
  331. /// </returns>
  332. public override string ToString() => Name;
  333. private string DebuggerDisplay => $"{Name} ({Id})";
  334. //Emotes
  335. /// <inheritdoc />
  336. public Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null)
  337. => GuildHelper.GetEmoteAsync(this, Discord, id, options);
  338. /// <inheritdoc />
  339. public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null)
  340. => GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options);
  341. /// <inheritdoc />
  342. /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception>
  343. public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null)
  344. => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options);
  345. /// <inheritdoc />
  346. public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null)
  347. => GuildHelper.DeleteEmoteAsync(this, Discord, emote.Id, options);
  348. //IGuild
  349. /// <inheritdoc />
  350. bool IGuild.Available => Available;
  351. /// <inheritdoc />
  352. IAudioClient IGuild.AudioClient => null;
  353. /// <inheritdoc />
  354. IRole IGuild.EveryoneRole => EveryoneRole;
  355. /// <inheritdoc />
  356. IReadOnlyCollection<IRole> IGuild.Roles => Roles;
  357. /// <inheritdoc />
  358. async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options)
  359. => await GetBansAsync(options).ConfigureAwait(false);
  360. /// <inheritdoc/>
  361. async Task<IBan> IGuild.GetBanAsync(IUser user, RequestOptions options)
  362. => await GetBanAsync(user, options).ConfigureAwait(false);
  363. /// <inheritdoc/>
  364. async Task<IBan> IGuild.GetBanAsync(ulong userId, RequestOptions options)
  365. => await GetBanAsync(userId, options).ConfigureAwait(false);
  366. /// <inheritdoc />
  367. async Task<IReadOnlyCollection<IGuildChannel>> IGuild.GetChannelsAsync(CacheMode mode, RequestOptions options)
  368. {
  369. if (mode == CacheMode.AllowDownload)
  370. return await GetChannelsAsync(options).ConfigureAwait(false);
  371. else
  372. return ImmutableArray.Create<IGuildChannel>();
  373. }
  374. /// <inheritdoc />
  375. async Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options)
  376. {
  377. if (mode == CacheMode.AllowDownload)
  378. return await GetChannelAsync(id, options).ConfigureAwait(false);
  379. else
  380. return null;
  381. }
  382. /// <inheritdoc />
  383. async Task<IReadOnlyCollection<ITextChannel>> IGuild.GetTextChannelsAsync(CacheMode mode, RequestOptions options)
  384. {
  385. if (mode == CacheMode.AllowDownload)
  386. return await GetTextChannelsAsync(options).ConfigureAwait(false);
  387. else
  388. return ImmutableArray.Create<ITextChannel>();
  389. }
  390. /// <inheritdoc />
  391. async Task<ITextChannel> IGuild.GetTextChannelAsync(ulong id, CacheMode mode, RequestOptions options)
  392. {
  393. if (mode == CacheMode.AllowDownload)
  394. return await GetTextChannelAsync(id, options).ConfigureAwait(false);
  395. else
  396. return null;
  397. }
  398. /// <inheritdoc />
  399. async Task<IReadOnlyCollection<IVoiceChannel>> IGuild.GetVoiceChannelsAsync(CacheMode mode, RequestOptions options)
  400. {
  401. if (mode == CacheMode.AllowDownload)
  402. return await GetVoiceChannelsAsync(options).ConfigureAwait(false);
  403. else
  404. return ImmutableArray.Create<IVoiceChannel>();
  405. }
  406. /// <inheritdoc />
  407. async Task<IReadOnlyCollection<ICategoryChannel>> IGuild.GetCategoriesAsync(CacheMode mode, RequestOptions options)
  408. {
  409. if (mode == CacheMode.AllowDownload)
  410. return await GetCategoryChannelsAsync(options).ConfigureAwait(false);
  411. else
  412. return null;
  413. }
  414. /// <inheritdoc />
  415. async Task<IVoiceChannel> IGuild.GetVoiceChannelAsync(ulong id, CacheMode mode, RequestOptions options)
  416. {
  417. if (mode == CacheMode.AllowDownload)
  418. return await GetVoiceChannelAsync(id, options).ConfigureAwait(false);
  419. else
  420. return null;
  421. }
  422. /// <inheritdoc />
  423. async Task<IVoiceChannel> IGuild.GetAFKChannelAsync(CacheMode mode, RequestOptions options)
  424. {
  425. if (mode == CacheMode.AllowDownload)
  426. return await GetAFKChannelAsync(options).ConfigureAwait(false);
  427. else
  428. return null;
  429. }
  430. /// <inheritdoc />
  431. async Task<ITextChannel> IGuild.GetDefaultChannelAsync(CacheMode mode, RequestOptions options)
  432. {
  433. if (mode == CacheMode.AllowDownload)
  434. return await GetDefaultChannelAsync(options).ConfigureAwait(false);
  435. else
  436. return null;
  437. }
  438. /// <inheritdoc />
  439. async Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options)
  440. {
  441. if (mode == CacheMode.AllowDownload)
  442. return await GetEmbedChannelAsync(options).ConfigureAwait(false);
  443. else
  444. return null;
  445. }
  446. /// <inheritdoc />
  447. async Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options)
  448. {
  449. if (mode == CacheMode.AllowDownload)
  450. return await GetSystemChannelAsync(options).ConfigureAwait(false);
  451. else
  452. return null;
  453. }
  454. /// <inheritdoc />
  455. async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, Action<TextChannelProperties> func, RequestOptions options)
  456. => await CreateTextChannelAsync(name, func, options).ConfigureAwait(false);
  457. /// <inheritdoc />
  458. async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options)
  459. => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false);
  460. /// <inheritdoc />
  461. async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, RequestOptions options)
  462. => await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);
  463. /// <inheritdoc />
  464. async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
  465. => await GetIntegrationsAsync(options).ConfigureAwait(false);
  466. /// <inheritdoc />
  467. async Task<IGuildIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options)
  468. => await CreateIntegrationAsync(id, type, options).ConfigureAwait(false);
  469. /// <inheritdoc />
  470. async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options)
  471. => await GetInvitesAsync(options).ConfigureAwait(false);
  472. /// <inheritdoc />
  473. async Task<IInviteMetadata> IGuild.GetVanityInviteAsync(RequestOptions options)
  474. => await GetVanityInviteAsync(options).ConfigureAwait(false);
  475. /// <inheritdoc />
  476. IRole IGuild.GetRole(ulong id)
  477. => GetRole(id);
  478. /// <inheritdoc />
  479. async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
  480. => await CreateRoleAsync(name, permissions, color, isHoisted, options).ConfigureAwait(false);
  481. /// <inheritdoc />
  482. async Task<IGuildUser> IGuild.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
  483. {
  484. if (mode == CacheMode.AllowDownload)
  485. return await GetUserAsync(id, options).ConfigureAwait(false);
  486. else
  487. return null;
  488. }
  489. /// <inheritdoc />
  490. async Task<IGuildUser> IGuild.GetCurrentUserAsync(CacheMode mode, RequestOptions options)
  491. {
  492. if (mode == CacheMode.AllowDownload)
  493. return await GetCurrentUserAsync(options).ConfigureAwait(false);
  494. else
  495. return null;
  496. }
  497. /// <inheritdoc />
  498. async Task<IGuildUser> IGuild.GetOwnerAsync(CacheMode mode, RequestOptions options)
  499. {
  500. if (mode == CacheMode.AllowDownload)
  501. return await GetOwnerAsync(options).ConfigureAwait(false);
  502. else
  503. return null;
  504. }
  505. /// <inheritdoc />
  506. async Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options)
  507. {
  508. if (mode == CacheMode.AllowDownload)
  509. return (await GetUsersAsync(options).FlattenAsync().ConfigureAwait(false)).ToImmutableArray();
  510. else
  511. return ImmutableArray.Create<IGuildUser>();
  512. }
  513. /// <inheritdoc />
  514. /// <exception cref="NotSupportedException">Downloading users is not supported for a REST-based guild.</exception>
  515. Task IGuild.DownloadUsersAsync() =>
  516. throw new NotSupportedException();
  517. async Task<IReadOnlyCollection<IAuditLogEntry>> IGuild.GetAuditLogsAsync(int limit, CacheMode cacheMode, RequestOptions options)
  518. {
  519. if (cacheMode == CacheMode.AllowDownload)
  520. return (await GetAuditLogsAsync(limit, options).FlattenAsync().ConfigureAwait(false)).ToImmutableArray();
  521. else
  522. return ImmutableArray.Create<IAuditLogEntry>();
  523. }
  524. /// <inheritdoc />
  525. async Task<IWebhook> IGuild.GetWebhookAsync(ulong id, RequestOptions options)
  526. => await GetWebhookAsync(id, options).ConfigureAwait(false);
  527. /// <inheritdoc />
  528. async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options)
  529. => await GetWebhooksAsync(options).ConfigureAwait(false);
  530. }
  531. }