// Path: src/main/java/stream/flarebot/flarebot/Getters.java
// public class Getters {
// 
//     private static FlareBot flareBot() {
//         return FlareBot.instance();
//     }
// 
//     // getXCache
//     public static SnowflakeCacheView<Guild> getGuildCache() {
//         return getShardManager().getGuildCache();
//     }
// 
//     public static SnowflakeCacheView<TextChannel> getTextChannelCache() {
//         return getShardManager().getTextChannelCache();
//     }
// 
//     public static SnowflakeCacheView<VoiceChannel> getVoiceChannelCache() {
//         return getShardManager().getVoiceChannelCache();
//     }
// 
//     public static SnowflakeCacheView<User> getUserCache() {
//         return getShardManager().getUserCache();
//     }
// 
//     // getXById
//     @Nullable
//     public static TextChannel getChannelById(String id) {
//         return getShardManager().getTextChannelById(id);
//     }
// 
//     @Nullable
//     public static TextChannel getChannelById(long id) {
//         return getShardManager().getTextChannelById(id);
//     }
// 
//     @Nullable
//     public static Guild getGuildById(String id) {
//         return getShardManager().getGuildById(id);
//     }
// 
//     @Nullable
//     public static Guild getGuildById(long id) {
//         return getShardManager().getGuildById(id);
//     }
// 
//     @Nullable
//     public static Emote getEmoteById(long emoteId) {
//         return getShardManager().getEmoteById(emoteId);
//     }
// 
//     @Nullable
//     public static User getUserById(String id) {
//         return getShardManager().getUserById(id);
//     }
// 
//     @Nullable
//     public static User getUserById(long id) {
//         return getShardManager().getUserById(id);
//     }
// 
//     @Nullable
//     public static Role getRoleById(String id) {
//         return getShardManager().getRoleById(id);
//     }
// 
//     @Nullable
//     public static Role getRoleById(long id) {
//         return getShardManager().getRoleById(id);
//     }
// 
// 
//     @Nullable
//     public static User retrieveUserById(long id) {
//         try {
//             return flareBot().getClient().retrieveUserById(id).complete();
//         } catch (ErrorResponseException e) {
//             return null;
//         }
//     }
// 
//     // Audio
//     public static long getConnectedVoiceChannels() {
//         return getShardManager().getGuildCache().stream()
//                 .filter(c -> c.getAudioManager().getConnectedChannel() != null).count();
//     }
// 
//     public static Set<VoiceChannel> getConnectedVoiceChannel() {
//         return getShardManager().getGuildCache().stream().filter(c -> c.getAudioManager().getConnectedChannel() != null)
//                 .map(g -> g.getAudioManager().getConnectedChannel())
//                 .collect(Collectors.toSet());
//     }
// 
//     public static long getActiveVoiceChannels() {
//         return getShardManager().getGuildCache().stream()
//                 .filter(c -> c.getAudioManager().getConnectedChannel() != null)
//                 .map(g -> flareBot().getMusicManager().getPlayer(g.getId()))
//                 .filter(p -> p != null && p.getPlayingTrack() != null && !p.getPaused())
//                 .count();
//     }
// 
//     public static int getSongsQueued() {
//         return flareBot().getMusicManager().getPlayers().stream()
//                 .mapToInt(p -> p.getPlaylist().size())
//                 .sum();
//     }
// 
//     // Other
//     public static List<JDA> getShards() {
//         return flareBot().getShardManager().getShards();
//     }
// 
//     @Nonnull
//     public static SelfUser getSelfUser() {
//         return flareBot().getClient().getSelfUser();
//     }
// 
//     @Nonnull
//     public static ShardManager getShardManager() {
//         return flareBot().getShardManager();
//     }
// 
//     public static Guild getOfficialGuild() {
//         return getGuildById(Constants.OFFICIAL_GUILD);
//     }
// }


import io.prometheus.client.Collector;
import io.prometheus.client.GaugeMetricFamily;
import stream.flarebot.flarebot.Getters;
import stream.flarebot.flarebot.metrics.BotMetrics;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
package stream.flarebot.flarebot.metrics.collectors;



public class BotCollector extends Collector {

    private final BotMetrics botMetrics;

    public BotCollector(BotMetrics botMetrics) {
        this.botMetrics = botMetrics;
    }

    @Override
    public List<MetricFamilySamples> collect() {

        List<MetricFamilySamples> familySamples = new ArrayList<>();

        GaugeMetricFamily jdaEntities = new GaugeMetricFamily("flarebot_jda_entities_total", "Amount of JDA entities",
                Collections.singletonList("entity"));
        familySamples.add(jdaEntities);

        GaugeMetricFamily playerInfo = new GaugeMetricFamily("flarebot_player_info",
                "Amount of players, playing players and songs queued", Collections.singletonList("amount"));
        familySamples.add(playerInfo);

        if (botMetrics.count()) {
            jdaEntities.addMetric(Collections.singletonList("guilds"), botMetrics.getGuildCount());
            jdaEntities.addMetric(Collections.singletonList("users"), botMetrics.getUserCount());
            jdaEntities.addMetric(Collections.singletonList("text_channels"), botMetrics.getTextChannelCount());
            jdaEntities.addMetric(Collections.singletonList("voice_channels"), botMetrics.getVoiceChannelCount());

// Path: src/main/java/stream/flarebot/flarebot/Getters.java
// public class Getters {
// 
//     private static FlareBot flareBot() {
//         return FlareBot.instance();
//     }
// 
//     // getXCache
//     public static SnowflakeCacheView<Guild> getGuildCache() {
//         return getShardManager().getGuildCache();
//     }
// 
//     public static SnowflakeCacheView<TextChannel> getTextChannelCache() {
//         return getShardManager().getTextChannelCache();
//     }
// 
//     public static SnowflakeCacheView<VoiceChannel> getVoiceChannelCache() {
//         return getShardManager().getVoiceChannelCache();
//     }
// 
//     public static SnowflakeCacheView<User> getUserCache() {
//         return getShardManager().getUserCache();
//     }
// 
//     // getXById
//     @Nullable
//     public static TextChannel getChannelById(String id) {
//         return getShardManager().getTextChannelById(id);
//     }
// 
//     @Nullable
//     public static TextChannel getChannelById(long id) {
//         return getShardManager().getTextChannelById(id);
//     }
// 
//     @Nullable
//     public static Guild getGuildById(String id) {
//         return getShardManager().getGuildById(id);
//     }
// 
//     @Nullable
//     public static Guild getGuildById(long id) {
//         return getShardManager().getGuildById(id);
//     }
// 
//     @Nullable
//     public static Emote getEmoteById(long emoteId) {
//         return getShardManager().getEmoteById(emoteId);
//     }
// 
//     @Nullable
//     public static User getUserById(String id) {
//         return getShardManager().getUserById(id);
//     }
// 
//     @Nullable
//     public static User getUserById(long id) {
//         return getShardManager().getUserById(id);
//     }
// 
//     @Nullable
//     public static Role getRoleById(String id) {
//         return getShardManager().getRoleById(id);
//     }
// 
//     @Nullable
//     public static Role getRoleById(long id) {
//         return getShardManager().getRoleById(id);
//     }
// 
// 
//     @Nullable
//     public static User retrieveUserById(long id) {
//         try {
//             return flareBot().getClient().retrieveUserById(id).complete();
//         } catch (ErrorResponseException e) {
//             return null;
//         }
//     }
// 
//     // Audio
//     public static long getConnectedVoiceChannels() {
//         return getShardManager().getGuildCache().stream()
//                 .filter(c -> c.getAudioManager().getConnectedChannel() != null).count();
//     }
// 
//     public static Set<VoiceChannel> getConnectedVoiceChannel() {
//         return getShardManager().getGuildCache().stream().filter(c -> c.getAudioManager().getConnectedChannel() != null)
//                 .map(g -> g.getAudioManager().getConnectedChannel())
//                 .collect(Collectors.toSet());
//     }
// 
//     public static long getActiveVoiceChannels() {
//         return getShardManager().getGuildCache().stream()
//                 .filter(c -> c.getAudioManager().getConnectedChannel() != null)
//                 .map(g -> flareBot().getMusicManager().getPlayer(g.getId()))
//                 .filter(p -> p != null && p.getPlayingTrack() != null && !p.getPaused())
//                 .count();
//     }
// 
//     public static int getSongsQueued() {
//         return flareBot().getMusicManager().getPlayers().stream()
//                 .mapToInt(p -> p.getPlaylist().size())
//                 .sum();
//     }
// 
//     // Other
//     public static List<JDA> getShards() {
//         return flareBot().getShardManager().getShards();
//     }
// 
//     @Nonnull
//     public static SelfUser getSelfUser() {
//         return flareBot().getClient().getSelfUser();
//     }
// 
//     @Nonnull
//     public static ShardManager getShardManager() {
//         return flareBot().getShardManager();
//     }
// 
//     public static Guild getOfficialGuild() {
//         return getGuildById(Constants.OFFICIAL_GUILD);
//     }
// }


// Path: src/main/java/stream/flarebot/flarebot/metrics/collectors/BotCollector.java
import io.prometheus.client.Collector;
import io.prometheus.client.GaugeMetricFamily;
import stream.flarebot.flarebot.Getters;
import stream.flarebot.flarebot.metrics.BotMetrics;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

package stream.flarebot.flarebot.metrics.collectors;



public class BotCollector extends Collector {

    private final BotMetrics botMetrics;

    public BotCollector(BotMetrics botMetrics) {
        this.botMetrics = botMetrics;
    }

    @Override
    public List<MetricFamilySamples> collect() {

        List<MetricFamilySamples> familySamples = new ArrayList<>();

        GaugeMetricFamily jdaEntities = new GaugeMetricFamily("flarebot_jda_entities_total", "Amount of JDA entities",
                Collections.singletonList("entity"));
        familySamples.add(jdaEntities);

        GaugeMetricFamily playerInfo = new GaugeMetricFamily("flarebot_player_info",
                "Amount of players, playing players and songs queued", Collections.singletonList("amount"));
        familySamples.add(playerInfo);

        if (botMetrics.count()) {
            jdaEntities.addMetric(Collections.singletonList("guilds"), botMetrics.getGuildCount());
            jdaEntities.addMetric(Collections.singletonList("users"), botMetrics.getUserCount());
            jdaEntities.addMetric(Collections.singletonList("text_channels"), botMetrics.getTextChannelCount());
            jdaEntities.addMetric(Collections.singletonList("voice_channels"), botMetrics.getVoiceChannelCount());

            playerInfo.addMetric(Collections.singletonList("connected_voice_channels"), Getters.getConnectedVoiceChannels());