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()); }
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)); }
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)); }
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>(); }
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); }
public UserModule(STDTContext db) : base() { _db = db; }
public StaffModule(STDTContext db, CommandHandler commandHandler) { _db = db; _commands = commandHandler; }