Пример #1
0
        public async Task Timers()
        {
            var timers = RuntimeInformation.Timers.RunningTimers.Where(x => x.CreatorID == Context.User.Id);

            if (!timers.Any())
            {
                await ReplyAsync("You don't have any running timers.");

                return;
            }

            var embedBuilder = MessagingUtils.GetShrimpbotEmbedBuilder();

            embedBuilder.WithTitle("Your running timers");
            embedBuilder.WithAuthor(Context.User);
            int i = 1;

            foreach (var timer in timers)
            {
                embedBuilder.AddField($"Timer #{i}",
                                      $"**Elapses**: {MessagingUtils.GetLengthString(timer.Elapses - DateTime.UtcNow)}\n" +
                                      $"**Message**: {timer.Message}", inline: true);
                i++;
            }
            await ReplyAsync(embed : embedBuilder.Build());
        }
Пример #2
0
        public async Task Daily()
        {
            var runner = Database.GetUser(Context.User.Id);

            if (DateTime.UtcNow - runner.DailyLastClaimed >= new TimeSpan(1, 0, 0, 0))
            {
                var responses = new string[]
                {
                    "You helped Squid fix bugs in FMP and got {0} {1}.",
                    "You beat theBeat out of the water and got {0} {1} for your hard work.",
                    "The dev did a fucky wucky."
                };

                string  response    = responses[rng.Next(0, responses.Length - 1)];
                decimal moneygained = (decimal)Math.Round(50 * runner.DailyBonus);
                runner.Money           += moneygained;
                runner.DailyBonus      += 0.1;
                runner.DailyLastClaimed = DateTime.UtcNow;
                await ReplyAsync(string.Format(response, moneygained, Config.Currency));
            }
            else
            {
                await ReplyAsync($"You already worked for Squid today. Try again in {MessagingUtils.GetLengthString((runner.DailyLastClaimed + new TimeSpan(1, 0, 0, 0)) - DateTime.UtcNow)}.");

                return;
            }
            Database.WriteUser(runner);
        }
Пример #3
0
        public async Task Timer(TimeSpan length, [Remainder] string?message = null)
        {
            if (length.Ticks <= 0)
            {
                await ReplyAsync("Timer has to run for longer than 0 seconds");

                return;
            }

            await ReplyAsync($"Timer has been set for {MessagingUtils.GetLengthString(length)}.");

            RuntimeInformation.Timers.CreateTimer(Context.User, message, length);
        }