Ejemplo n.º 1
0
        public async Task SystemFrontPercent(Context ctx, PKSystem system)
        {
            if (system == null)
            {
                throw Errors.NoSystemError;
            }
            ctx.CheckSystemPrivacy(system, system.FrontHistoryPrivacy);

            string durationStr = ctx.RemainderOrNull() ?? "30d";

            var now = SystemClock.Instance.GetCurrentInstant();

            var rangeStart = PluralKit.Utils.ParseDateTime(durationStr, true, system.Zone);

            if (rangeStart == null)
            {
                throw Errors.InvalidDateTime(durationStr);
            }
            if (rangeStart.Value.ToInstant() > now)
            {
                throw Errors.FrontPercentTimeInFuture;
            }

            var frontpercent = await _data.GetFrontBreakdown(system, rangeStart.Value.ToInstant(), now);

            await ctx.Reply(embed : await _embeds.CreateFrontPercentEmbed(frontpercent, system.Zone));
        }
Ejemplo n.º 2
0
        public async Task SystemFrontPercent([Remainder] string durationStr = "30d")
        {
            var system = ContextEntity ?? Context.SenderSystem;

            if (system == null)
            {
                throw Errors.NoSystemError;
            }

            var now = SystemClock.Instance.GetCurrentInstant();

            var rangeStart = PluralKit.Utils.ParseDateTime(durationStr);

            if (rangeStart == null)
            {
                throw Errors.InvalidDateTime(durationStr);
            }
            if (rangeStart.Value.ToInstant() > now)
            {
                throw Errors.FrontPercentTimeInFuture;
            }

            var frontpercent = await Switches.GetPerMemberSwitchDuration(system, rangeStart.Value.ToInstant(), now);

            await Context.Channel.SendMessageAsync(embed : await EmbedService.CreateFrontPercentEmbed(frontpercent, system.Zone));
        }