} // For a friend that inspired pets to begin with <3 public void DoChecks(PetGame pet) { if (lastNeglected == default) { lastNeglected = pet.bornDate; } else if (pet.TotalStats == 0) { lastNeglected = DateTime.Now; } double days = (DateTime.Now - lastNeglected).TotalDays; if (!string.IsNullOrWhiteSpace(pet.petName) && !string.IsNullOrWhiteSpace(pet.petImageUrl)) { Custom = true; } if (days >= 180 && Attention < 4) { Attention = 4; } else if (days >= 30 && Attention < 3) { Attention = 3; } else if (days >= 14 && Attention < 2) { Attention = 2; } else if (days >= 7 && Attention < 1) { Attention = 1; } }
public async Task PetImage(PetGame pet, string args) { string url = args ?? Context.Message.Attachments.FirstOrDefault()?.Url; if (url == null && pet.PetImageUrl == null) { await ReplyAsync($"{CustomEmoji.Cross} Please specify an image! You can use a link or upload your own."); } else { try { pet.PetImageUrl = url; } catch (FormatException) { await ReplyAsync($"{CustomEmoji.Cross} Invalid image link!\nYou can try uploading the image yourself."); return; } if (url == null) { await ReplyAsync($"{CustomEmoji.Check} Pet image reset!"); } else { await AutoReactAsync(); } } }
public async Task PetMaster(string commandName = "", [Remainder] string args = null) { var command = typeof(MoreGamesModule).GetMethods() .FirstOrDefault(x => x.GetCustomAttribute <PetCommandAttribute>()?.Names.Contains(commandName.ToLower()) ?? false); if (command == null) { await ReplyAsync($"Unknown pet command! Do `{Prefix}pet help` for help"); } else { var pet = Storage.GetUserGame <PetGame>(Context.User.Id); if (pet == null) { if (commandName == "") { pet = new PetGame("", Context.User.Id, Services); Storage.AddGame(pet); } else { await ReplyAsync($"You don't have a pet yet! Simply do `{Prefix}pet` to adopt one."); return; } } await(Task) command.Invoke(this, new object[] { pet, args }); } }
public async Task PetUser(PetGame pet, string args) { if (string.IsNullOrWhiteSpace(args)) { await ReplyAsync("You must specify a user!"); return; } var user = await Context.ParseUserAsync(args); if (user == null) { await ReplyAsync("Can't find the specified user!"); return; } pet = Storage.GetUserGame <PetGame>(user.Id); if (pet == null) { await ReplyAsync("This person doesn't have a pet :("); } else { await ReplyAsync(pet.GetContent(), pet.GetEmbed(user)); } }
public async Task PetWake(PetGame pet, string args) { pet.UpdateStats(false); await ReplyAsync(pet.asleep? "🌅 You wake up your pet." : "🌅 Your pet is already awake."); if (pet.asleep) { pet.ToggleSleep(); } }
public async Task PetClean(PetGame pet, string args) { if (pet.Clean()) { await Context.Message.AddReactionAsync(Bot.Random.Choose(PetGame.CleanEmotes).ToEmoji()); } else { await ReplyAsync($"{CustomEmoji.Cross} Your pet is already clean! (-1 happiness)"); } }
public async Task PetRelease(PetGame pet, string args) { if (string.IsNullOrWhiteSpace(pet.PetName) || args?.SanitizeMarkdown().SanitizeMentions() == pet.PetName) { Storage.DeleteGame(pet); await ReplyAsync($"Goodbye {(string.IsNullOrWhiteSpace(pet.PetName) ? pet.Name : pet.PetName)}!"); } else { await ReplyAsync($"❗ Are you sure you want to delete {pet.PetName}? It will be gone forever, along with your stats and achievements, " + $"and you can't get it back. Do **{Prefix}pet release {pet.PetName}** to release."); } }
public async Task PetPlay(PetGame pet, string args) { if (pet.Play()) { await Context.Message.AddReactionAsync(Bot.Random.Choose(PetGame.PlayEmotes).ToEmoji()); } else { string message = pet.energy.Ceiling() >= 5 ? "Your pet doesn't want to play anymore! (-1 happiness)" : "Your pet is too tired to play! It needs 5 energy or more."; await ReplyAsync($"{CustomEmoji.Cross} {message}"); } }
public async Task PetName(PetGame pet, string args) { if (string.IsNullOrWhiteSpace(args)) { await ReplyAsync($"{CustomEmoji.Cross} Please specify a name!"); } else if (args.Length > 32) { await ReplyAsync($"{CustomEmoji.Cross} Pet name can't go above 32 characters!"); } else { pet.PetName = args; await AutoReactAsync(); } }
public async Task PetSleep(PetGame pet, string args) { pet.UpdateStats(store: false); if (pet.energy.Ceiling() == PetGame.MaxStat && !pet.asleep) { pet.happiness = Math.Max(0, pet.happiness - 1); Games.Save(pet); await ReplyAsync($"{CustomEmoji.Cross} Your pet is not tired! (-1 happiness)"); } else { string message = pet.asleep ? "Your pet is already sleeping." : "Your pet is now asleep."; await ReplyAsync($"{Bot.Random.Choose(PetGame.SleepEmotes)} {message}"); if (!pet.asleep) { pet.ToggleSleep(); } } }
public async Task PetExact(PetGame pet, string args) { var user = Context.User as SocketGuildUser; if (!string.IsNullOrWhiteSpace(args)) { var other = await Context.ParseUserAsync(args); if (other != null) { user = other; pet = Storage.GetUserGame <PetGame>(user.Id); if (pet == null) { await ReplyAsync("This person doesn't have a pet :("); return; } } } await ReplyAsync(pet.GetContent(), pet.GetEmbed(user, decimals: true)); }
public async Task PetPet(PetGame pet, string args) { var now = DateTime.Now; if (now - pet.petTimerStart > TimeSpan.FromMinutes(1)) { pet.petTimerStart = now; pet.timesPetSinceTimerStart = 0; } int limit = Context.Guild == null ? 15 : 5; if (pet.timesPetSinceTimerStart >= limit) { await ReplyAsync($"{CustomEmoji.Cross} That's enough petting! Try again in a minute" + (Context.Guild == null ? "." : ", or pet in a DM with the bot.")); } else { pet.timesPetSinceTimerStart += 1; await ReplyAsync(pet.DoPet()); } }
public async Task PetStats(PetGame pet, string args) { var user = Context.User as SocketGuildUser; if (!string.IsNullOrWhiteSpace(args)) { var other = await Context.ParseUserAsync(args); if (other != null) { user = other; pet = Games.GetForUser <PetGame>(user.Id); if (pet == null) { await ReplyAsync("This person doesn't have a pet :("); return; } } } await ReplyAsync(pet.GetEmbedAchievements(user)); }
public async Task Pet(PetGame pet, string args) { await ReplyAsync(pet.GetContent(), pet.GetEmbed(Context.User as IGuildUser)); }
public async Task PetHelp(PetGame pet, string args) { var summary = typeof(MoreGamesModule).GetMethod(nameof(PetMaster)).GetCustomAttribute <SummaryAttribute>(); await ReplyAsync(summary?.Text.Replace("{prefix}", Prefix) ?? "Couldn't get help"); }
public async Task PetHelp(PetGame pet, string args) { await GetModule <GeneralModule>().SendCommandHelp("pet"); }