Added Group Role functionality for Add and Remove.
This commit is contained in:
1 parent
cb5d2b7e85
commit
aa79a30956
4 files changed
+39
-17
No files matched your search
@@ -34,12 +34,33 @@ namespace StarsiegeBot
|
||||
public async Task ListGroups(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string gId = ctx.Guild.Id.ToString();
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
|
||||
|
||||
embed.WithTitle($"{ctx.Guild.Name} Groups");
|
||||
embed.WithDescription("An overview of all role groups.");
|
||||
foreach (KeyValuePair<string, Dictionary<string, int>> item in GuildSettings[gId].SelfRoles)
|
||||
{
|
||||
embed.AddField(item.Key, item.Value.Count.ToString());
|
||||
}
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
[Command("add")]
|
||||
public async Task AddGroup(CommandContext ctx, [RemainingText] string groupName)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string gId = ctx.Guild.Id.ToString();
|
||||
if (GuildSettings[gId].SelfRoles.ContainsKey(groupName))
|
||||
{
|
||||
await ctx.RespondAsync($"The group `{groupName}` already exists.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = new Dictionary<string, int>();
|
||||
GuildSettings[gId].SelfRoles.Add(groupName, temp);
|
||||
await ctx.RespondAsync($"The group `{groupName}` was added.");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Delete all roles or assign new group?
|
||||
@@ -47,12 +68,24 @@ namespace StarsiegeBot
|
||||
public async Task RemoveGroup(CommandContext ctx, [RemainingText] string groupName)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string gId = ctx.Guild.Id.ToString();
|
||||
if (GuildSettings[gId].SelfRoles.ContainsKey(groupName))
|
||||
{
|
||||
GuildSettings[gId].SelfRoles.Remove(groupName);
|
||||
await ctx.RespondAsync($"Group `{groupName}` removed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
await ctx.RespondAsync($"The group `{groupName}` doesn't exist.");
|
||||
}
|
||||
}
|
||||
|
||||
[Command("edit")]
|
||||
public async Task EditGroup(CommandContext ctx, [RemainingText] string groupInfo)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string gId = ctx.Guild.Id.ToString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user