Exemple #1
0
 public Listener GetListener(SocketGuild G, SocketGuildUser Bot, SocketGuildUser Listener)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         return(GetListenerList(G, Bot).FirstOrDefault(l => l.UserID == Listener.Id));
     }
 }
Exemple #2
0
 public Reminder GetReminderConfig(SocketGuild G, SocketGuildUser Bot)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         return(SC.Reminders.FirstOrDefault(r => r.GuildId == G.Id && r.BotId == Bot.Id));
     }
 }
Exemple #3
0
 public List <Reminder> GetGuildReminders(SocketGuild G)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         return(SC.Reminders.AsQueryable().Where(rc => rc.GuildId == G.Id).ToList());
     }
 }
Exemple #4
0
        public async Task <List <List <string> > > ExecSql(string query)
        {
            using (StatusBotContext SC = new StatusBotContext())
            {
                var       db      = SC.Database;
                DbCommand command = db.GetDbConnection().CreateCommand();
                command.CommandText = query;
                await db.OpenConnectionAsync();

                DbDataReader reader = await command.ExecuteReaderAsync();

                var columnNames = Enumerable.Range(0, reader.FieldCount).Select(reader.GetName).ToList();
                var records     = new List <List <string> >();
                records.Add(columnNames);
                while (await reader.ReadAsync())
                {
                    var row = new List <string>();
                    foreach (var colname in columnNames)
                    {
                        string data = (reader[colname].ToString().EscapeCSV());
                        row.Add(data);
                    }
                    records.Add(row);
                }
                reader.Close();
                return(records);
            }
        }
Exemple #5
0
 public BotConfig GetBotConfig(SocketSelfUser Bot)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         return(SC.BotConfigs.FirstOrDefault(c => c.BotId == Bot.Id));
     }
 }
Exemple #6
0
 public List <Listener> GetListenerList(Reminder RC)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         var ReminderId = RC.ReminderId;
         return(SC.Listeners.AsQueryable().Where(l => l.ReminderId == ReminderId).ToList());
     }
 }
Exemple #7
0
 public List <Listener> GetListenerList(SocketGuild G, SocketGuildUser Bot)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         var RC         = GetReminderConfig(G, Bot);
         var ReminderId = RC.ReminderId;
         return(SC.Listeners.AsQueryable().Where(l => l.ReminderId == ReminderId).ToList());
     }
 }
Exemple #8
0
 public async Task DelListener(SocketGuild G, SocketGuildUser Bot, SocketGuildUser Listener)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         var L = GetListener(G, Bot, Listener);
         SC.Remove(L);
         await SC.SaveChangesAsync();
     }
 }
Exemple #9
0
 public async Task DelReminder(SocketGuild G, SocketGuildUser Bot)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         var RC = GetReminderConfig(G, Bot);
         SC.Remove(RC);
         await SC.SaveChangesAsync();
     }
 }
Exemple #10
0
 public async Task ModifyReminderDuration(SocketGuild G, SocketGuildUser Bot, int duration)
 {
     using (StatusBotContext SC = new StatusBotContext())
     {
         //Not using GetReminder(G, Bot) in order for the entity to be tracked by the context to be updated
         var RC = SC.Reminders.FirstOrDefault(r => r.GuildId == G.Id && r.BotId == Bot.Id);
         RC.Duration = duration;
         await SC.SaveChangesAsync();
     }
 }
Exemple #11
0
        public async Task AddListener(SocketGuild G, SocketGuildUser Bot, SocketGuildUser Listener)
        {
            using (StatusBotContext SC = new StatusBotContext())
            {
                var L = new Listener
                {
                    UserID     = Listener.Id,
                    ReminderId = GetReminderConfig(G, Bot).ReminderId,
                };
                await SC.AddAsync(L); //Adds the Listener to the LISTENERs table

                await SC.SaveChangesAsync();
            }
        }
Exemple #12
0
        public async Task AddReminder(SocketGuild G, SocketGuildUser Bot, bool x, int duration)
        {
            using (StatusBotContext SC = new StatusBotContext())
            {
                var RC = new Reminder
                {
                    GuildId  = G.Id,
                    BotId    = Bot.Id,
                    Active   = x,
                    Duration = duration,
                };
                RC.Listeners = new List <Listener>()
                {
                };
                await SC.AddAsync(RC);

                await SC.SaveChangesAsync();
            }
        }