public async Task NewDayAsync() { if (!StateChecker.IsKnockoutChannel(Context) || StateChecker.IsPrivateMessage(Context)) { return; } if (!(StateChecker.IsChannelOp(Context))) { await Context.Channel.SendMessageAsync(":x: You are not a bot moderator!"); return; } if (Context.IsPrivate) { await Context.Channel.SendMessageAsync("Please use this command in the knockout channel!"); return; } var knockouts = new KnockOutHandler(Context.Channel.Id, Factory.GetDatabase()); knockouts.NewDay(); await Context.Channel.SendMessageAsync("It is a glorious new day. Everyone's turns are reset!"); return; }
public async Task HelpAsync() { if (!StateChecker.IsKnockoutChannel(Context)) { await Context.Channel.SendMessageAsync( "**!createknockout** - Creates a new knockout, instructions follow in a private message.\n" + "(please don't forget to type **!quit** if you change your mind or the bot will remain locked in creation mode!\n" + "**!vote** *<Up>*/*<Down>* - Vote for the contenders you wish to raise and decrease.\n" + "**!showknockout** - Refresh and show the current knockout at the bottom of the screen.\n" + "**!epitaph** *<eulogy for the fallen* - Use this to type a silly little message to honor the contender you last eliminated.\n" + "**!snap** - Halve the current scores, can only be used by the knockout creator.\n" + "**!newday** - Reset the counters for the hour, can only be used by channel ops.\n" + "**!rebuild** - Completely delete the current or in progress knockout. Only for channel ops! Use with caution!\n" + "Have fun! If I break, please let RedFlint know!" ); return; } if (!StateChecker.IsGeneralChannel(Context)) { await Context.Channel.SendMessageAsync( "**!ver** - Show the latest version of the bot.\n" + "**!weather** *<Location>* - Show a simple weather report for that location.\n" + "Have fun! If I break, please let RedFlint know!" ); return; } }
public async Task EpitaphAsync([Remainder] string input = "") { if (!StateChecker.IsKnockoutChannel(Context) || StateChecker.IsPrivateMessage(Context)) { return; } if (input == "") { await Context.Channel.SendMessageAsync(":x: Please enter a valid epitaph."); return; } if (input.Count() > 199) { await Context.Channel.SendMessageAsync(":x: Epitaph too long!"); } var knockouts = new KnockOutHandler(Context.Channel.Id, Factory.GetDatabase()); switch (knockouts.KnockoutStatus) { case 1: await Context.Channel.SendMessageAsync(":x: No Knockout ongoing. Feel free to start a new one!"); return; case 2: break; case 3: await Context.Channel.SendMessageAsync(":x: This knockout is finished."); return; case 4: await Context.Channel.SendMessageAsync(":x: This knockout is still under construction! Patience!"); return; default: await Context.Channel.SendMessageAsync(":x: Right. This shouldn't have happened. Someone call RedFlint."); return; } if (!knockouts.CanWriteAnEpitaph(Context.User.Id)) { await Context.Channel.SendMessageAsync(":x: You are not eligible to write an epitaph for a contender."); return; } knockouts.WriteEpitaphFromUser(Context.User.Id, input); await Context.Channel.SendMessageAsync(":skull: Engraved!"); }
public async Task AddKnockoutAsync() { if (!StateChecker.IsKnockoutChannel(Context) || StateChecker.IsPrivateMessage(Context)) { return; } var knockouts = new KnockOutHandler(Context.Channel.Id, Factory.GetDatabase()); switch (knockouts.KnockoutStatus) { case 1: break; case 2: await Context.Channel.SendMessageAsync(":x: A knockout is already in progress!"); return; case 3: break; case 4: await Context.Channel.SendMessageAsync(":x: A knockout is already being built by someone, sorry!"); return; default: await Context.Channel.SendMessageAsync(":x: Right. This shouldn't have happened. Someone call RedFlint."); break; } await Discord.UserExtensions.SendMessageAsync(Context.User, "Commands to create your own Knockout (all commands in this window please):\n\n" + "**!name** _The Name Of Your Knockout_\n" + "**!add** _The Name of Your Knockout Contender to add (no slashes please! I'm afraid Face/Off is not allowed for now!)_\n" + "**!remove** _The Name of a Knockout Contender to delete (case sensitive)_\n" + "**!preview** _Preview your Knockout_\n" + "**!begin** _Start your Knockout, NO CHANGES CAN BE MADE BEYOND THIS POINT_\n" + "**!quit** _Abandon and Delete your Knockout_\n" ); knockouts.CreateNewKnockout(Context.User.Id); await BotEmbeds.DraftBeingCreated(Context, knockouts); return; }
public async Task EmbedKnockoutAsync() { if (!StateChecker.IsKnockoutChannel(Context) || StateChecker.IsPrivateMessage(Context)) { return; } var knockouts = new KnockOutHandler(Context.Channel.Id, Factory.GetDatabase()); switch (knockouts.KnockoutStatus) { case 1: await Context.Channel.SendMessageAsync(":x: No Knockout has been created or is being created. Go for it! Type !createknockout to begin."); return; case 2: await BotEmbeds.ShowKnockout(Context, knockouts); return; case 3: await BotEmbeds.KnockoutIsOver(Context, knockouts); break; case 4: var userId = knockouts.KnockoutCreatorUlong; var username = Context.Client.GetUser(userId).Username; await Context.Channel.SendMessageAsync($"This Knockout is currently under construction by **{username}**! Feel free to advise!"); await BotEmbeds.ShowKnockout(Context, knockouts); return; default: await Context.Channel.SendMessageAsync(":x: Right. This shouldn't have happened. Someone call RedFlint."); return; } }
public async Task RebuildDatabasesAsync() { if (!StateChecker.IsKnockoutChannel(Context) || StateChecker.IsPrivateMessage(Context)) { return; } if (!StateChecker.IsChannelOp(Context)) { await Context.Channel.SendMessageAsync(":x: You are not a channel op!"); return; } await Context.Channel.SendMessageAsync("!!! All databases are being rebuilt and purged !!!"); var knockouts = new KnockOutHandler(Context.Channel.Id, Factory.GetDatabase()); knockouts.RebuildDataBase(); await Context.Channel.SendMessageAsync("!!! Done !!!"); }
public async Task PlayAsync([Remainder] string input = "") { if (!StateChecker.IsKnockoutChannel(Context) || StateChecker.IsPrivateMessage(Context)) { return; } if (input == "") { await Context.Channel.SendMessageAsync(":x: Please enter your options in this format: *!vote choice to add/choice to delete*"); return; } if (!input.Contains("/") || input.Count(c => c == '/') > 1) { await Context.Channel.SendMessageAsync(":x: Please enter your options in this format: *!vote choice to add/choice to delete*"); return; } var choices = input.Split('/'); var choiceToAdd = choices.First(); var choiceToSub = choices.Last(); var knockouts = new KnockOutHandler(Context.Channel.Id, Factory.GetDatabase()); switch (knockouts.KnockoutStatus) { case 1: await Context.Channel.SendMessageAsync(":x: No Knockout ongoing. Feel free to start a new one!"); return; case 2: break; case 3: await Context.Channel.SendMessageAsync(":x: This knockout is finished. Feel free to start a new one!"); return; case 4: await Context.Channel.SendMessageAsync(":x: This knockout is still under construction! Patience!"); return; default: await Context.Channel.SendMessageAsync(":x: Right. This shouldn't have happened. Someone call RedFlint."); return; } if (knockouts.PlayerWentLastTime(Context.User.Id)) { await Context.Channel.SendMessageAsync(":x: You just went! Give a few other people a chance!"); return; } if (knockouts.TurnsLeftForPlayer(Context.User.Id) <= 0) { await Context.Channel.SendMessageAsync(":x: You are out of turns, please wait until the turns are reset"); return; } var original = choiceToAdd; choiceToAdd = knockouts.FindNearestMatch(choiceToAdd); if (choiceToAdd == "ERROR") { await Context.Channel.SendMessageAsync($":x: I'm sorry, I could not find a close match for **{original}**, please try again"); return; } original = choiceToSub; choiceToSub = knockouts.FindNearestMatch(choiceToSub); if (choiceToSub == "ERROR") { await Context.Channel.SendMessageAsync($":x: I'm sorry, I could not find a close match for **{original}**, please try again"); return; } if (choiceToAdd == choiceToSub) { await Context.Channel.SendMessageAsync(":x: Choices are the same, try again."); return; } knockouts.ApplyVoteChanges(choiceToAdd, choiceToSub, Context.User.Id); if (knockouts.LivingContendersCount <= 3) { knockouts.EndKnockout(); await BotEmbeds.KnockoutIsOver(Context, knockouts); } else { var userName = Context.User.Username; var avatarUrl = Context.User.GetAvatarUrl(); await Context.Channel.SendMessageAsync("", false, BotEmbeds.PlayerVotingReportEmbed(userName, avatarUrl, choiceToAdd, choiceToSub)); var recentKiller = knockouts.PlayerHasJustKilled(); if (recentKiller != 0) { var killer = Context.Client.GetUser(recentKiller); if (killer != null) { await killer.SendMessageAsync("You have killed a contender, type !epitaph _<message>_ in the main channel to leave a mark on their grave!"); await killer.SendMessageAsync("(please note, if you eliminate another contender, you will lose the opportunity to engrave an epitaph for this one)"); } knockouts.GetContendersFromDb(); } await BotEmbeds.ShowKnockout(Context, knockouts); } }