private void raid_list_impl(Context ctx) { //Generate the list of raids var raids = RaidManager.EnumerateRaids() .Select(r => RaidManager.GetRaidData(r)) .Where(r => r.HasValue).Select(r => r.Value) .ToList(); //Check that it's not empty if (raids.Count > 0) { //Go through each raid raids.ForEach(r => { //Display the raid Bot.GetBotInstance() .SendSuccessMessage(ctx.message.Channel, r.description, $"Roster size: {r.roster.Distinct().Count()}", $"ID: {r.raid_id} | Local time:", DateTimeOffset.FromUnixTimeSeconds(r.timestamp) ); }); } else { //No raids Bot.GetBotInstance() .SendSuccessMessage(ctx.message.Channel, "Result:", $"None."); } }
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."); }
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." ); }