public override async Task Execute(ClientCommand commandData) { Player p = application.Players.Find(x => x.Name == commandData.Sender.Username); if (p == null) { p = application.AddPlayer(commandData.SenderIdString, commandData.Sender.Username); } string challengeName = commandData.Arguments[0]; string postingPlayerId = p.DiscordId; string identifier = Regex.Replace(challengeName, "[^0-9]", ""); int weaponId = 0; //if (identifier.Length < 1) // await commandData.Respond($"You forgot a number in the title {Emotes.ERROR}"); if (!int.TryParse(commandData.Arguments[1], out weaponId)) { await commandData.Respond($"Invalid input in selected weapon {Emotes.ERROR}"); } else { Weapon weapon = (Weapon)weaponId; string weaponShort = Regex.Replace(weapon.ToString(), "[^A-Z]", ""); identifier += weaponShort; identifier = MakeUniqueIdentifier(identifier); application.AddChallenge(challengeName, weapon, postingPlayerId, identifier); await commandData.Respond($"`{challengeName} ({identifier})`{Emotes.WeaponsArray[(int)weapon]} created"); } }
public override async Task Execute(ClientCommand commandData) { string identifier = commandData.Arguments[0]; Challenge c = application.Challenges.Find(x => x.Identifier == identifier); if (c == null) { await commandData.Respond($"Challenge with identifier \"{identifier}\" does not exist {Emotes.ERROR}"); } else { application.RemoveChallenge(identifier); await commandData.Respond($"`{c.Name} ({c.Identifier})`{Emotes.WeaponsArray[(int)c.Weapon]} was removed"); } }
public override async Task Execute(ClientCommand commandData) { IList <Challenge> challenges = application.Challenges; if (challenges.Count <= 0) { await commandData.Respond($"There are no challenges {Emotes.ERROR}"); } else { string list = ""; foreach (Challenge c in challenges) { Player creator = application.Players.Find(x => x.DiscordId == c.PlayerDiscordId); list += $"```{c.Name} ({c.Identifier})\nWeapon: {c.Weapon.ToString()}, Posted by: {creator.Name}\n\n```"; } await commandData.Respond(list); } }
public override async Task Execute(ClientCommand commandData) { string identifier = commandData.Arguments[0]; string username = commandData.Arguments[1]; Challenge c = application.Challenges.Find(x => x.Identifier == identifier); Player p = application.Players.Find(x => x.Name == username); Score s = application.Scores.Find(x => x.ChallengeId == c?.Id && x.PlayerDiscordId == p?.DiscordId); if (s == null) { await commandData.Respond($"Either the challenge does not exist or the player is not on that challenge {Emotes.ERROR}"); } else { application.RemoveScore(s); await commandData.Respond($"{p.Name} was removed from `{c.Name} ({c.Identifier})`{Emotes.WeaponsArray[(int)c.Weapon]}"); } }
public override async Task Execute(ClientCommand commandData) { HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Add("User-Agent", "FluffyBot"); string json = httpClient.GetStringAsync("http://aws.random.cat/meow").Result; string link = Regex.Replace(json, "({\"file\":\"|\"}|\\\\)", ""); await commandData.Respond(link); }
public override async Task Execute(ClientCommand commandData) { string senderName = commandData.Sender.Username; string challengeIdentifier = commandData.Arguments[0].ToUpper(); string clearTime = commandData.Arguments[1]; //IReadOnlyCollection<Discord.Attachment> attachments = commandData.DiscordMessage.Attachments; Challenge challenge = application.Challenges.Find(x => x.Identifier == challengeIdentifier); if (challenge == null) { await commandData.Respond($"Challenge with the identifier {challengeIdentifier} does not exist {Emotes.ERROR}"); } else if (!CommandValidator.ValidClearTimeFormat(clearTime)) { await commandData.Respond($"Clear time format is wrong {Emotes.ERROR}"); } //else if (!CommandValidator.HasAttachment(commandData.DiscordMessage)) // await commandData.Respond($"No image was attached {Emotes.ERROR}"); else { Player player = application.Players.Find(x => x.Name == senderName); if (player == null) { player = application.AddPlayer(commandData.SenderIdString, senderName); } //string imageName = ""; //foreach (var attachment in commandData.DiscordMessage.Attachments) //{ // imageName = DownloadImage(attachment.Url, attachment.Filename); //} clearTime = Regex.Replace(clearTime, "(?<=\\d\\d'\\d\\d)'", "\""); application.AddScore(player.DiscordId, clearTime, challenge.Id); await commandData.Respond($"Your score was added! {Emotes.SUCCESS}"); } }
public override async Task Execute(ClientCommand commandData) { string legend = $"{Emotes.SNS} `Sword and Shield`\n" + $"{Emotes.DB} `Dual Blades`\n" + $"{Emotes.LS} `Long Sword`\n" + $"{Emotes.GS} `Great Sword`\n" + $"{Emotes.HA} `Hammer`\n" + $"{Emotes.HH} `Hunting Horn`\n" + $"{Emotes.SA} `Switch Axe`\n" + $"{Emotes.CB} `Charge Blade`\n" + $"{Emotes.LA} `Lance`\n" + $"{Emotes.GL} `Gunlance`\n" + $"{Emotes.LBG} `Light Bowgun`\n" + $"{Emotes.HBG} `Heavy Bowgun`\n" + $"{Emotes.IG} `Insect Glaive`\n" + $"{Emotes.BOW} `Bow`"; await commandData.Respond(legend); }
public override async Task Execute(ClientCommand commandData) { string response = ""; switch (commandData.Name) { case "!sns": response = Emotes.SNS; break; case "!db": response = Emotes.DB; break; case "!ls": response = Emotes.LS; break; case "!gs": response = Emotes.GS; break; case "!ha": case "!hammer": response = Emotes.HA; break; case "!hh": response = Emotes.HH; break; case "!sa": response = Emotes.SA; break; case "!cb": response = Emotes.CB; break; case "!la": case "!lance": response = Emotes.LA; break; case "!gl": response = Emotes.GL; break; case "!lbg": response = Emotes.LBG; break; case "!hbg": response = Emotes.HBG; break; case "!ig": response = Emotes.IG; break; case "!bow": response = Emotes.BOW; break; } await commandData.Respond(response); }