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)); } }
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)); } }
public static ClientGuildSettings GetGuildSettings(this DiscordSocketClient client, ulong guildId) { client.GetCachedGuild(guildId); try { return(client.GuildSettings[guildId]); } catch (KeyNotFoundException) { return(null); } }
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)); } }