示例#1
0
        private async Task DailyAsync()
        {
            await Context.Message.DeleteAsync();

            LoriUser profile = ProfileDatabase.GetUser(Context.User.Id);

            if (profile == null)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find your bank account.");

                return;
            }

            var  tgg      = LCommandHandler.GetTopGGClient();
            bool hasVoted = await tgg.HasVoted(Context.User.Id);

            if (hasVoted)
            {
                // check if already claimed
                if (ProfileDatabase.HasClaimedDaily(Context.User.Id))
                {
                    DateTime claimAt     = profile.Claimed.AddHours(12.0);
                    var      timeToClaim = claimAt - DateTime.Now;
                    await MessageUtil.SendErrorAsync(Context.Channel as ITextChannel, "Already Claimed", $"You can claim your daily in {timeToClaim.Hours} hours and {timeToClaim.Minutes} minutes.", false);
                }
                else
                {
                    ProfileDatabase.ClaimDaily(Context.User.Id);

                    float        newAmt = profile.GetCurrency();
                    EmbedBuilder embed  = new EmbedBuilder()
                    {
                        Color       = Color.DarkPurple,
                        Title       = "Daily Bonus Claimed",
                        Description = $"New bank balance: ${newAmt}"
                    };
                    await Context.Channel.SendMessageAsync(null, false, embed.Build());
                }
            }
            else
            {
                EmbedBuilder embed = new EmbedBuilder()
                {
                    Color  = Color.DarkPurple,
                    Author = new EmbedAuthorBuilder()
                    {
                        Name = "Click here to vote!", Url = "https://top.gg/bot/729696788097007717/vote"
                    },
                    Description = $"Vote on TopGG and then claim your daily!",
                    Footer      = new EmbedFooterBuilder()
                    {
                        Text = "If you can't click above, head to this url https://top.gg/bot/729696788097007717/vote"
                    }
                };
                await Context.Channel.SendMessageAsync(null, false, embed.Build());
            }
        }