Exemplo n.º 1
0
        internal static Embed RaidEnded(STDTContext db, RaidInfo ri, IGuild guild)
        {
            List <RaidAttendee> Attendees = db.RaidAttendees.ToList().Where(x => x.RaidID == Globals._activeRaid.RaidID).ToList();
            var emb = new EmbedBuilder()
            {
                Color       = Globals.SuccessColor,
                Description = $"Raid {ri.RaidID} (started {ri.DateOfRaid}) Successfully Ended!\r\n" +
                              $"Counted {Attendees.Count} attendees.\r\n" + GetAttendeesString(),
                Footer = new EmbedFooterBuilder().WithIconUrl(_config[$"guilds:{guild.Id}:logo"]).WithText(_config[$"guilds:{guild.Id}:name"])
            };

            string GetAttendeesString()
            {
                StringBuilder sb = new StringBuilder();

                Attendees.ForEach(x =>
                {
                    User DBuser = db.Users.Find(x.UserID);

                    sb.AppendLine($"{DBuser.Username} - {x.MinutesInRaid} minutes - {x.PointsObtained} points.");
                });

                return(sb.ToString());
            }

            return(emb.Build());
        }
Exemplo n.º 2
0
        private bool CommandAllowedInChannel(CommandInfo command, STDTContext db, IGuildChannel channel)
        {
            List <long> AllowedChannelIDs = db.CommandChannelPermissions.ToList().Where(x => x.CommandName.ToLower() == command.Name.ToLower()).Select(x => x.ChannelID).ToList();

            if (AllowedChannelIDs.Count == 0)
            {
                return(true);
            }

            return(AllowedChannelIDs.Contains((long)channel.Id));
        }
Exemplo n.º 3
0
        public CooldownService(DiscordSocketClient client, IConfigurationRoot config, STDTContext db)
        {
            _client = client;
            _config = config;
            _db     = db;

            _timer = new Timer(_ =>
            {
                var tasks = new List <Task>();
                tasks.Add(Task.Factory.StartNew(async() => { await CheckCooldowns().ConfigureAwait(false); }));
            },
                               null,
                               TimeSpan.Zero,
                               TimeSpan.FromSeconds(3));
        }
Exemplo n.º 4
0
        public CommandHandler(DiscordSocketClient discord, CommandService commands, IConfigurationRoot config, IServiceProvider services, STDTContext context)
        {
            _client   = discord;
            _commands = commands;
            _config   = config;
            _provider = services;
            _db       = context;

            _client.UserJoined            += OnUserJoined;
            _client.MessageReceived       += OnMessageReceieved;
            _client.UserVoiceStateUpdated += OnUserVoiceStateUpdated;
            _client.GuildMemberUpdated    += OnUserUpdated;
            _client.GuildAvailable        += OnGuildAvailable;



            _voiceMembersJoinedTimer = new Dictionary <IUser, DateTime>();
        }
Exemplo n.º 5
0
        private bool CommandAllowedByRole(CommandInfo command, STDTContext db, IGuildUser user, IGuild guild)
        {
            var perm = db.CommandRolePermissions.Find(command.Name);

            if (perm is null)
            {
                return(true);
            }

            var guildRoles  = guild.Roles;
            var userMinRole = guild.GetRole((ulong)perm.MinimumRole);

            foreach (var role in guildRoles)
            {
                if (role.Position >= userMinRole.Position)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
 public UserModule(STDTContext db) : base()
 {
     _db = db;
 }
Exemplo n.º 7
0
 public StaffModule(STDTContext db, CommandHandler commandHandler)
 {
     _db       = db;
     _commands = commandHandler;
 }