Exemple #1
0
 public static void Update(MainConfig mess)
 {
     using var con = new SQLiteConnection(path);
     con.Open();
     using var cmd   = new SQLiteCommand(con);
     cmd.CommandText = "UPDATE mainconfig SET muteroleid = @muteroleid, autoroleid =@autoroleid, logchannelid = @logchannel, prefix=@prefix WHERE serverid = @id;";
     cmd.Parameters.AddWithValue("@id", mess.serverid);
     cmd.Parameters.AddWithValue("@muteroleid", mess.muteroleid);
     cmd.Parameters.AddWithValue("@autoroleid", mess.autoroleid);
     cmd.Parameters.AddWithValue("@logchannel", mess.logchannelid);
     cmd.Parameters.AddWithValue("@prefix", mess.prefix);
     cmd.Prepare();
     cmd.ExecuteNonQuery();
 }
Exemple #2
0
        public static MainConfig GetMessage(ulong serverid)
        {
            MainConfig mess = new MainConfig();

            using var con = new SQLiteConnection(path);
            con.Open();

            string stm;

            stm = "SELECT * FROM mainconfig WHERE serverid=" + serverid;

            using var cmd = new SQLiteCommand(stm, con);
            using SQLiteDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                mess.serverid     = Convert.ToUInt64(rdr.GetInt64(0));
                mess.muteroleid   = Convert.ToUInt64(rdr.GetInt64(1));
                mess.autoroleid   = Convert.ToUInt64(rdr.GetInt64(2));
                mess.logchannelid = Convert.ToUInt64(rdr.GetInt64(3));
                mess.prefix       = rdr.GetString(4);
            }
            return(mess);
        }