예제 #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));
     }
 }
예제 #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));
     }
 }
예제 #4
0
        public static ClientGuildSettings GetGuildSettings(this DiscordSocketClient client, ulong guildId)
        {
            client.GetCachedGuild(guildId);

            try
            {
                return(client.GuildSettings[guildId]);
            }
            catch (KeyNotFoundException)
            {
                return(null);
            }
        }
예제 #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));
     }
 }