public void raid_kick(Context ctx, uint id, ulong userID) { //Get a handle to the raid var handle = RaidManager.GetRaidFromID((int)id); //Make sure it exists Precondition.Assert(handle.HasValue, $"No raid with that id ({id})."); //Find the raider that matches the ID var player = RaidManager.FindRaider(handle.Value, userID); //Check that the raider exists in the roster Precondition.Assert(player.HasValue, "That raider is not in the roster."); //Pass on to the implementation this.raid_kick_impl(ctx, handle.Value, player.Value); }
public void raid_leave(Context ctx, uint id) { //Get a handle to the raid var handle = RaidManager.GetRaidFromID((int)id); //Make sure it exists Precondition.Assert(handle.HasValue, $"No raid with that id ({id})."); //Find the raider in the roster var player = RaidManager.FindRaider(handle.Value, ctx.message.Author.Id); //Check that the raider exists in the roster Precondition.Assert(player.HasValue, "You are not in the roster."); //Pass on to the implementation this.raid_leave_impl(ctx, handle.Value, player.Value); }
private void raid_roster_impl(Context ctx, int id, string roles) { //Get a handle to the raid var handle = RaidManager.GetRaidFromID(id).Value; //Extract the roles to create our filter var filter = this.raidConfig.MatchRoles(roles); //Get the raiders that match the filter var roster = RaidManager.CoalesceRaiders(handle) .Where(e => e.roles.Intersect(filter).Count() > 0) .ToList(); //Check that it's not empty if (roster.Count > 0) { //Resolve their names and roles var tmp = roster.Select(e => { //Get the name var name = (e.user_id.HasValue) ? Bot.GetBotInstance().GetUserName(e.user_id.Value) : e.user_name; //Check if this entry is a backup if (e.backup) { //Add the roles and cursive style return($"*{name} - {string.Join(", ", e.roles)}*"); } //Add the roles return($"{name} - {string.Join(", ", e.roles)}"); }).ToList(); //Display the roster Bot.GetBotInstance() .SendSuccessMessage(ctx.message.Channel, "Result:", string.Join("\n", tmp), $"Count: {tmp.Count}"); } else { //Empty roster Bot.GetBotInstance() .SendSuccessMessage(ctx.message.Channel, "Result:", $"None"); } }
public void raid_kick(Context ctx, uint id, [RegexParameter(@"[\S\s]+")] string name) { //Get a handle to the raid var handle = RaidManager.GetRaidFromID((int)id); //Make sure it exists Precondition.Assert(handle.HasValue, $"No raid with that id ({id})."); //Find any raiders that match the name var players = RaidManager.FindRaiders(handle.Value, name); //Check that we got only one Precondition.Assert(players.Count > 0, "No one with that name."); Precondition.Assert(players.Count == 1, $"More than one matches that name."); //Pass on to the implementation this.raid_kick_impl(ctx, handle.Value, players.First()); }
public void raid_make_comp(Context ctx, [RegexParameter(@"[\S\s]+")] string name, uint id) { //Get a handle to the raid var handle = RaidManager.GetRaidFromID((int)id); //Make sure it exists Precondition.Assert(handle.HasValue, $"No raid with that id ({id}"); //Check that the composition exists string[] layout; Precondition.Assert ( this.raidConfig.Compositions.TryGetValue(name.ToUpper(), out layout), "No comp with that name. These are the recognised comps: \n" + string.Join(", ", this.raidConfig.Compositions.Keys) ); //Pass on to the implementation this.raid_make_comp_impl(ctx, handle.Value, layout); }
private void raid_add_impl(Context ctx, int id, string name, string roles) { //Get a handle to the raid var handle = RaidManager.GetRaidFromID(id).Value; //Extract the roles var extractedRoles = this.raidConfig.MatchRoles(roles); bool bu = roles.ToUpper().Contains("BACKUP"); //Check that we got any roles Precondition.Assert(extractedRoles.Length > 0, "No recognized roles provided!"); //Add to the raid RaidManager.AppendRaider(handle, name, bu, extractedRoles); //Return success Bot.GetBotInstance() .SendSuccessMessage(ctx.message.Channel, "Success", $"They were added to the raid{(bu ? " as backup" : "")} with these roles: \"{string.Join(", ", extractedRoles)}\"." ); }
private void raid_delete_impl(Context ctx, int id) { //Get a handle to the raid var handle = RaidManager.GetRaidFromID(id).Value; //Grab the data from the raid var data = RaidManager.GetRaidData(handle); //Check that it's valid Precondition.Assert(data.HasValue, "There was an error processing the raid."); //Get the owner var owner_id = data.Value.owner_id; //Check that the user is the owner Precondition.Assert(ctx.message.Author.Id == owner_id, "You are not the owner of the raid!"); //Delete the raid RaidManager.DeleteRaid(handle); //Return success Bot.GetBotInstance() .SendSuccessMessage(ctx.message.Channel, "Success", $"Raid has been deleted."); }