Exemplo n.º 1
0
        public static IReadOnlyList <DiscordVoiceState> GetGuildVoiceStates(this DiscordSocketClient client, ulong guildId)
        {
            if (!client.Config.Cache)
            {
                throw new NotSupportedException("Caching is disabled for this client.");
            }

            return(client.GetCachedGuild(guildId).VoiceStates);
        }
 /// <summary>
 /// Gets a guild's channels
 /// </summary>
 /// <param name="guildId">ID of the guild</param>
 public static IReadOnlyList <GuildChannel> GetGuildChannels(this DiscordSocketClient client, ulong guildId)
 {
     if (client.Config.Cache)
     {
         return(client.GetCachedGuild(guildId).Channels);
     }
     else
     {
         return(((DiscordClient)client).GetGuildChannels(guildId));
     }
 }
Exemplo n.º 3
0
 public static async Task <IReadOnlyList <DiscordEmoji> > GetGuildEmojisAsync(this DiscordSocketClient client, ulong guildId)
 {
     if (client.Config.Cache)
     {
         return(client.GetCachedGuild(guildId).Emojis);
     }
     else
     {
         return(await((DiscordClient)client).GetGuildEmojisAsync(guildId));
     }
 }
Exemplo n.º 4
0
        public static ClientGuildSettings GetGuildSettings(this DiscordSocketClient client, ulong guildId)
        {
            client.GetCachedGuild(guildId);

            try
            {
                return(client.GuildSettings[guildId]);
            }
            catch (KeyNotFoundException)
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 public static async Task <DiscordEmoji> GetGuildEmojiAsync(this DiscordSocketClient client, ulong guildId, ulong emojiId)
 {
     if (client.Config.Cache)
     {
         try
         {
             return(client.GetCachedGuild(guildId).Emojis.First(e => e.Id == emojiId));
         }
         catch (InvalidOperationException)
         {
             throw new DiscordHttpException(new DiscordHttpError(DiscordError.UnknownEmoji, "Emoji was not found in cache"));
         }
     }
     else
     {
         return(await((DiscordClient)client).GetGuildEmojiAsync(guildId, emojiId));
     }
 }