Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions BLART/Commands/RoleCommands/RoleListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,37 @@ public partial class RoleCommands
[SlashCommand("list", "Lists available self-assignable roles.")]
public async Task ListRoles()
{
Dictionary<string, string> roles = new Dictionary<string, string>
{
["Plugin Roles"] = "## Plugin Roles\n",
["Misc Roles"] = "## Miscellaneous Roles\n"
};

await DeferAsync(ephemeral: true);

List<ulong> roleIds = DatabaseHandler.GetSelfRoles();
EmbedBuilder builder = new();
builder.WithTitle("Self-Assignable Roles");
builder.WithFooter(EmbedBuilderService.Footer);
builder.WithCurrentTimestamp();
string description = string.Empty;
foreach (ulong roleId in roleIds)
description += $"<@&{roleId}>\n";
builder.WithDescription(description);
foreach (ulong roleId in roleIds)
{
var role = Context.Guild.Roles.FirstOrDefault(role => role.Id == roleId);

if (role is null)
continue;

var channel = Context.Guild.TextChannels.FirstOrDefault(channel => channel.Name.ToLower() == role.Name.ToLower());
if (channel is not null)
{
roles["Plugin Roles"] += $"<@&{roleId}> - Role for <#{channel.Id}>.\n";
}
else
{
roles["Misc Roles"] += $"<@&{roleId}>\n";
}
}
builder.WithDescription(roles["Plugin Roles"] + "\n" + roles["Misc Roles"]);
builder.WithColor(Color.Green);

await FollowupAsync(embed: builder.Build(), ephemeral: true);
Expand Down