using Discord;
using Discord.Interactions;

namespace Flux_System_Assistant.CommandModules;

public class FactionCommands : InteractionModuleBase<SocketInteractionContext>
{
    [SlashCommand("register-factions", "Scans the server for existing factions and implements them into the database")]
    public async Task RegisterFactions()
    {
        var client = Context.Client;
        var currentGuild = Context.Guild;

        await DeferAsync();

        var embed = new EmbedBuilder()
            .WithAuthor(Context.User)
            .WithTitle("Associating Categories with Roles: ");

        var embedField = new EmbedFieldBuilder()
            .WithName("Testingfield")
            .WithValue("Hello There")
            .WithIsInline(true);

        string descriptor = String.Empty;

        foreach(var groupChannel in currentGuild.CategoryChannels)
        {
            descriptor += $"{groupChannel} / {currentGuild.Roles.FirstOrDefault(x => x.Name == groupChannel.Name)?.Mention ?? "Not Found"}";
            descriptor += "\n";
        }

        embed.WithDescription(descriptor);
        embed.AddField(embedField);

        await FollowupAsync(embed: embed.Build());
    }
    
}