Example #1
0
        public async override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            var guildId  = context.Guild.Id;
            var trackers = StaticBase.Trackers[Type].GetGuildTrackers(guildId);

            if (trackers.Count() < Limit)
            {
                return(PreconditionResult.FromSuccess());
            }

            return(PreconditionResult.FromError($"Your server exceeded the limit of {Limit} {Type.ToString()}-Trackers.\nTo add another tracker, get below the limit first."));
        }
 public BtTrackerActivity(TrackerType trackerType)
 {
     this.trackerType = trackerType;
     title = trackerType.ToString();
     icon = UIImage.FromBundle(trackerType.ActivityImageName());
 }
        public async override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            var guildId  = context.Guild.Id;
            var trackers = StaticBase.Trackers[Type].GetGuildTrackers(guildId);

            int countTrackers = 0;

            foreach (var tracker in trackers)
            {
                countTrackers += tracker.ChannelConfig.Keys.Where(x => (context.Guild as SocketGuild).GetTextChannel(x) != null).Count();
            }

            if (countTrackers < Limit)
            {
                return(PreconditionResult.FromSuccess());
            }

            return(PreconditionResult.FromError($"Your server exceeded the limit of {Limit} {Type.ToString()}-Trackers.\nTo add another tracker, get below the limit first."));
        }
Example #4
0
 public TrackerLimitAttribute(TrackerType type)
 {
     Type  = type;
     Limit = Program.TrackerLimits[type.ToString()]["TrackersPerServer"];
 }