Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate role list into plugin roles and non-plugin roles #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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