private void raid_leave_impl(Context ctx, RaidHandle handle, Entry e) { //Remove from the raid RaidManager.RemoveRaider(handle, e); //Return success Bot.GetBotInstance() .SendSuccessMessage(ctx.message.Channel, "Success", $"You were removed from the roster." ); }
private void raid_kick_impl(Context ctx, RaidHandle handle, Entry e) { //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!"); //Remove from the raid RaidManager.RemoveRaider(handle, e); //Return success Bot.GetBotInstance() .SendSuccessMessage(ctx.message.Channel, "Success", $"They were removed from the roster." ); }
private void raid_make_comp_impl(Context ctx, RaidHandle handle, /*readonly*/ string[] layout) { //Get the raiders var raiders = RaidManager.CoalesceRaiders(handle); //Generate composition var result = this.GenerateComp(raiders, layout, out Entry[] unused); //Setup the embed builder var builder = new EmbedBuilder().WithColor(Color.Blue); //Get the unique roles in this composition var roles = layout.Distinct().ToArray(); //Go through each role foreach (var r in roles) { //Count the instances of this role in the layout var roleCount = layout.Count(str => r == str); //Get all players with this assigned role var players = result.Where(p => p.assignment == r); //Format the names var formatted = players.Select(p => { //Get the name of the player var name = (p.player.user_id.HasValue ? Bot.GetBotInstance().GetUserName(p.player.user_id.Value) : p.player.user_name); //Check if backup if (p.player.backup) { //Add cursive return($"*{name}*"); } else { return(name); } }).ToArray(); //Check that it's not empty if (formatted.Length > 0) { //Write the formatted names builder = builder.AddField($"{r} ({formatted.Length}/{roleCount}):", string.Join('\n', formatted)); } else { //Add an empty field builder = builder.AddField($"{r} (0/{roleCount}):", "..."); } } //Check if we need to add a "not included" category if (unused.Length > 0) { //Format the names var formatted = unused.Select(p => { //Get the name of the player var name = (p.user_id.HasValue ? Bot.GetBotInstance().GetUserName(p.user_id.Value) : p.user_name); //Check if backup if (p.backup) { //Add cursive return($"*{name}*"); } else { return(name); } }).ToArray(); //Add the field builder = builder.AddField("Not included:", string.Join('\n', formatted)); } //Build the embed var embed = builder.WithTitle("This is the best comp I could make:") .Build(); //Send the message ctx.message.Channel.SendMessageAsync("", false, embed).GetAwaiter().GetResult(); }